N=int(eval(input()))

S=eval(input())



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



#j-i= k-j k=2*j-i



for i in range(N):

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

    if 2*j-i<N:

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

        ans -=1

        

print(ans)

      

    

    
N=int(eval(input()))

S=eval(input())



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



#j-i= k-j k=2*j-i



for i in range(N):

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

    if 2*j-i>=N:

      break

      

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

      ans -=1

        

print(ans)

      

    

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

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

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