n = int(eval(input()))

s = str(eval(input()))

rn = s.count("R")

gn = s.count("G")

bn = s.count("B")



ct=0

for i in range(n):

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

    if 2*j - i >= n:

      break

    elif s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:

      ct += 1

 

print((rn*gn*bn-ct))
n = int(eval(input()))

s = str(eval(input()))

rn = s.count("R")

gn = s.count("G")

bn = s.count("B")

 

ct=0

for i in range(n):

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

    k = 2*j - i

    if k >= n:

      break

    elif s[i]!=s[j] and s[j]!=s[k]and s[i]!=s[k]:

      ct += 1

 

print((rn*gn*bn-ct))
n = int(eval(input()))
s = str(eval(input()))
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")
ct = 0
for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i >= n:
            break
        elif s[i] != s[j] and s[j] != s[2 * j - i] and s[i] != s[2 * j - i]:
            ct += 1
print((rn * gn * bn - ct))

n = int(eval(input()))
s = str(eval(input()))
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")
ct = 0
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ct += 1
print((rn * gn * bn - ct))

-        if 2 * j - i >= n: +        k = 2 * j - i +        if k >= n: -        elif s[i] != s[j] and s[j] != s[2 * j - i] and s[i] != s[2 * j - i]: +        elif s[i] != s[j] and s[j] != s[k] and s[i] != s[k]: