n=int(eval(input()))

s=eval(input())

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

for j in range(n):

  for i in range(j):

    if (k:=2*j-i)<n:

      if s[i]!=s[k]!=s[j]!=s[i]:

        ans-=1   

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

s=eval(input())

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

for j in range(n):

  J=s[j]

  for i in range(j):

    k=2*j-i

    if k<n:

      I=s[i]

      K=s[k]

      if I!=J!=K!=I:

        ans-=1   

print(ans)
n = int(eval(input()))
s = eval(input())
ans = s.count("R") * s.count("G") * s.count("B")
for j in range(n):
    for i in range(j):
        if (k := 2 * j - i) < n:
            if s[i] != s[k] != s[j] != s[i]:
                ans -= 1
print(ans)

n = int(eval(input()))
s = eval(input())
ans = s.count("R") * s.count("G") * s.count("B")
for j in range(n):
    J = s[j]
    for i in range(j):
        k = 2 * j - i
        if k < n:
            I = s[i]
            K = s[k]
            if I != J != K != I:
                ans -= 1
print(ans)

+    J = s[j] -        if (k := 2 * j - i) < n: -            if s[i] != s[k] != s[j] != s[i]: +        k = 2 * j - i +        if k < n: +            I = s[i] +            K = s[k] +            if I != J != K != I: