n=int(eval(input()))

s=eval(input())

r=g=b=0

for i in s:

  if i=="R":r+=1

  elif i=="G":g+=1

  else:b+=1

ans=r*g*b

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

  for j in range(n):

    if j+i+i>=n:break

    if not(s[j]==s[j+i] or s[j+i]==s[j+i+i] or s[j]==s[j+i+i]):ans-=1

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

s=eval(input())

r=g=b=0

for i in s:

  if i=="R":r+=1

  elif i=="G":g+=1

  else:b+=1

ans=r*g*b

for i in range(n-2):

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

    k=j+(j-i)

    if k>=n:break

    if not(s[i]==s[j] or s[j]==s[k] or s[i]==s[k]):ans-=1

print(ans)
n = int(eval(input()))
s = eval(input())
r = g = b = 0
for i in s:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    else:
        b += 1
ans = r * g * b
for i in range(1, n // 2 + 2):
    for j in range(n):
        if j + i + i >= n:
            break
        if not (s[j] == s[j + i] or s[j + i] == s[j + i + i] or s[j] == s[j + i + i]):
            ans -= 1
print(ans)

n = int(eval(input()))
s = eval(input())
r = g = b = 0
for i in s:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    else:
        b += 1
ans = r * g * b
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            break
        if not (s[i] == s[j] or s[j] == s[k] or s[i] == s[k]):
            ans -= 1
print(ans)

-for i in range(1, n // 2 + 2): -    for j in range(n): -        if j + i + i >= n: +for i in range(n - 2): +    for j in range(i + 1, n - 1): +        k = j + (j - i) +        if k >= n: -        if not (s[j] == s[j + i] or s[j + i] == s[j + i + i] or s[j] == s[j + i + i]): +        if not (s[i] == s[j] or s[j] == s[k] or s[i] == s[k]):