N=int(eval(input()))

S=eval(input())

ans=S.count("R")*S.count("G")*S.count("B")



for i in range(N):

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

    k=j+(j-i)

    if k<=N-1:

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

          ans-=1

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

S=eval(input())

ans=S.count("R")*S.count("G")*S.count("B")



for i in range(N):

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

    k=j+(j-i)

    if N-1<k:

      break



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

        ans-=1

        

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

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

-        if k <= N - 1: -            if S[j] != S[i] and S[j] != S[k] and S[k] != S[i]: -                ans -= 1 +        if N - 1 < k: +            break +        if S[j] != S[i] and S[j] != S[k] and S[k] != S[i]: +            ans -= 1