

n = int(eval(input()))

s = eval(input())



r = s.count("R")

g = s.count("G")

b = s.count("B")



ans = r * g * b





for i in range(n):

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

        if i-j < 0 or i+j > n-1:

            break

        if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]:

            ans -= 1

print(ans)



n = int(eval(input()))

s = eval(input())



r = s.count("R")

g = s.count("G")

b = s.count("B")



ans = r * g * b





for i in range(n):

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

        if i-j < 0 or i+j > n-1:

            continue

        if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]:

            ans -= 1

print(ans)



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

n = int(eval(input()))
s = eval(input())
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r * g * b
for i in range(n):
    for j in range(1, n // 2 + 1):
        if i - j < 0 or i + j > n - 1:
            continue
        if s[i] != s[i - j] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            ans -= 1
print(ans)

-            break +            continue