N = int(eval(input()))

S = eval(input())



r_num = S.count("R")

g_num = S.count("G")

b_num = S.count("B")



cnt = 0



for i in range(N - 2):

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

        if 2 * j - i < N and S[i] != S[j] and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]):

            cnt += 1



ans = r_num * g_num * b_num - cnt

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

S = eval(input())



r_num = S.count("R")

g_num = S.count("G")

b_num = S.count("B")



cnt = 0



for i in range(N - 2):

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

        if not 2 * j - i < N:

            break

        if S[i] != S[j] and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]):

            cnt += 1



ans = r_num * g_num * b_num - cnt

print(ans)

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

N = int(eval(input()))
S = eval(input())
r_num = S.count("R")
g_num = S.count("G")
b_num = S.count("B")
cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if not 2 * j - i < N:
            break
        if S[i] != S[j] and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]):
            cnt += 1
ans = r_num * g_num * b_num - cnt
print(ans)

-        if ( -            2 * j - i < N -            and S[i] != S[j] -            and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]) -        ): +        if not 2 * j - i < N: +            break +        if S[i] != S[j] and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]):