# -*- coding: utf-8 -*-

N = int(eval(input()))

S = eval(input())



R = 0

G = 0

B = 0



for i in range(N):

  if S[i] == 'R':

    R += 1

  elif S[i] == 'G':

    G += 1

  else:

    B += 1

    

count = 0

for i in range(N-1):

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

    if 2*j-i>=N:

      break

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

      count += 1



print((R*G*B-count))
# -*- coding: utf-8 -*-

N = int(eval(input()))

S = eval(input())



R = 0

G = 0

B = 0



for i in range(N):

  if S[i] == 'R':

    R += 1

  elif S[i] == 'G':

    G += 1

  else:

    B += 1



count = 0

for i in range(N-2):

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

    k = 2*j-i

    if k>=N:

      break

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

      count += 1



print((R*G*B-count))
# -*- coding: utf-8 -*-
N = int(eval(input()))
S = eval(input())
R = 0
G = 0
B = 0
for i in range(N):
    if S[i] == "R":
        R += 1
    elif S[i] == "G":
        G += 1
    else:
        B += 1
count = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if 2 * j - i >= N:
            break
        if S[i] != S[j] and S[2 * j - i] != S[i] and S[2 * j - i] != S[j]:
            count += 1
print((R * G * B - count))

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

-for i in range(N - 1): -    for j in range(i + 1, N): -        if 2 * j - i >= N: +for i in range(N - 2): +    for j in range(i + 1, N - 1): +        k = 2 * j - i +        if k >= N: -        if S[i] != S[j] and S[2 * j - i] != S[i] and S[2 * j - i] != S[j]: +        if S[i] != S[j] and S[k] != S[i] and S[k] != S[j]: