n=int(eval(input()))

s=list(eval(input()))

a=s.count("R")

b=s.count("G")

c=s.count("B")

ans=0

for i in range(n-2):

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

    k=2*j-i

    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 

      ans=ans+1

print((a*b*c-ans))
n=int(eval(input()))

s=eval(input())

a=s.count("R")

b=s.count("G")

c=s.count("B")

sum=0

for i in range(n-2):

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

    if 2*j-i<=n-1 and s[i]!=s[j] and s[j]!=s[2*j-i] and s[2*j-i]!=s[i]:

      sum=sum+1

print((a*b*c-sum))

      
n = int(eval(input()))
s = list(eval(input()))
a = s.count("R")
b = s.count("G")
c = s.count("B")
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = 2 * j - i
        if n - 1 >= k and (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]):
            ans = ans + 1
print((a * b * c - ans))

n = int(eval(input()))
s = eval(input())
a = s.count("R")
b = s.count("G")
c = s.count("B")
sum = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if (
            2 * j - i <= n - 1
            and s[i] != s[j]
            and s[j] != s[2 * j - i]
            and s[2 * j - i] != s[i]
        ):
            sum = sum + 1
print((a * b * c - sum))

-s = list(eval(input())) +s = eval(input()) -ans = 0 +sum = 0 -        k = 2 * j - i -        if n - 1 >= k and (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]): -            ans = ans + 1 -print((a * b * c - ans)) +        if ( +            2 * j - i <= n - 1 +            and s[i] != s[j] +            and s[j] != s[2 * j - i] +            and s[2 * j - i] != s[i] +        ): +            sum = sum + 1 +print((a * b * c - sum))