n=int(eval(input()))

s=eval(input())

nr=s.count('R')

ng=s.count('G')

nb=s.count('B')

ans=nr*ng*nb

for i in range(1,1+(n-1)//2):

      for j in range(n-2*i):

            if s[j]!=s[j+i] and s[j]!=s[2*i+j] and s[j+i]!=s[j+2*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*b*g

for i in range(1,(n-1)//2+1):

    for j in range(n):

        if j+i+i>n-1:

            break

        if s[j]!=s[j+i] and s[j+i]!=s[j+i+i] and s[j]!=s[j+i+i]:

            ans-=1

print(ans)
n = int(eval(input()))
s = eval(input())
nr = s.count("R")
ng = s.count("G")
nb = s.count("B")
ans = nr * ng * nb
for i in range(1, 1 + (n - 1) // 2):
    for j in range(n - 2 * i):
        if s[j] != s[j + i] and s[j] != s[2 * i + j] and s[j + i] != s[j + 2 * 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 * b * g
for i in range(1, (n - 1) // 2 + 1):
    for j in range(n):
        if j + i + i > n - 1:
            break
        if s[j] != s[j + i] and s[j + i] != s[j + i + i] and s[j] != s[j + i + i]:
            ans -= 1
print(ans)

-nr = s.count("R") -ng = s.count("G") -nb = s.count("B") -ans = nr * ng * nb -for i in range(1, 1 + (n - 1) // 2): -    for j in range(n - 2 * i): -        if s[j] != s[j + i] and s[j] != s[2 * i + j] and s[j + i] != s[j + 2 * i]: +r = s.count("R") +g = s.count("G") +b = s.count("B") +ans = r * b * g +for i in range(1, (n - 1) // 2 + 1): +    for j in range(n): +        if j + i + i > n - 1: +            break +        if s[j] != s[j + i] and s[j + i] != s[j + i + i] and s[j] != s[j + i + i]: