N = int(eval(input()))

S = eval(input())

R = S.count("R")

G = S.count("G")

ans = R*G*(N-R-G)



for i in range(N-2):

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

        k = 2*j - i

        if k < N:

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

                ans -= 1



            

print(ans)
N = int(eval(input()))

S = eval(input())

R = S.count("R")

G = S.count("G")

B = S.count("B")

 

ans = R*G*B

for i in range(N-2):

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

        k = 2*j - i

        if k < N:

            tmp = []

            tmp.append(S[i])

            tmp.append(S[j])

            tmp.append(S[k])

            if len(set(tmp)) == 3:

                ans -= 1

 

print(ans)
N = int(eval(input()))
S = eval(input())
R = S.count("R")
G = S.count("G")
ans = R * G * (N - R - G)
for i in range(N - 2):
    for j in range(i, N - 1):
        k = 2 * j - i
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)

N = int(eval(input()))
S = eval(input())
R = S.count("R")
G = S.count("G")
B = S.count("B")
ans = R * G * B
for i in range(N - 2):
    for j in range(i, N - 1):
        k = 2 * j - i
        if k < N:
            tmp = []
            tmp.append(S[i])
            tmp.append(S[j])
            tmp.append(S[k])
            if len(set(tmp)) == 3:
                ans -= 1
print(ans)

-ans = R * G * (N - R - G) +B = S.count("B") +ans = R * G * B -            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]: +            tmp = [] +            tmp.append(S[i]) +            tmp.append(S[j]) +            tmp.append(S[k]) +            if len(set(tmp)) == 3: