from collections import Counter

N = int(eval(input()))

S = [i for i in eval(input())]

count = 0

s = Counter(S)

for i in range(N):

    for j in range(i,N):

        if (i+j)%2==0 and S[(i+j)//2]!=S[i] and S[i]!=S[j] and S[(i+j)//2]!=S[j]:

            count += 1



print(((s['R'] * s['B'] * s['G'])-count))
N = int(eval(input()))

S = [i for i in eval(input())]



r = 0

g = 0

b = 0

no = 0



for i in S:

    if i == "R":

        r += 1

    elif i == "G":

        g += 1

    else:

        b += 1



for i in range(N):

    for j in range(i+1, N):

        k = j*2 - i

        if k >= N:

            break

        elif S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:

            no += 1

 

print((r*g*b - no))
from collections import Counter

N = int(eval(input()))
S = [i for i in eval(input())]
count = 0
s = Counter(S)
for i in range(N):
    for j in range(i, N):
        if (
            (i + j) % 2 == 0
            and S[(i + j) // 2] != S[i]
            and S[i] != S[j]
            and S[(i + j) // 2] != S[j]
        ):
            count += 1
print(((s["R"] * s["B"] * s["G"]) - count))

N = int(eval(input()))
S = [i for i in eval(input())]
r = 0
g = 0
b = 0
no = 0
for i in S:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    else:
        b += 1
for i in range(N):
    for j in range(i + 1, N):
        k = j * 2 - i
        if k >= N:
            break
        elif S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            no += 1
print((r * g * b - no))

-from collections import Counter - -count = 0 -s = Counter(S) +r = 0 +g = 0 +b = 0 +no = 0 +for i in S: +    if i == "R": +        r += 1 +    elif i == "G": +        g += 1 +    else: +        b += 1 -    for j in range(i, N): -        if ( -            (i + j) % 2 == 0 -            and S[(i + j) // 2] != S[i] -            and S[i] != S[j] -            and S[(i + j) // 2] != S[j] -        ): -            count += 1 -print(((s["R"] * s["B"] * s["G"]) - count)) +    for j in range(i + 1, N): +        k = j * 2 - i +        if k >= N: +            break +        elif S[i] != S[j] and S[j] != S[k] and S[k] != S[i]: +            no += 1 +print((r * g * b - no))