n = int(eval(input()))

s = eval(input())

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

for i in range(n):

    for d in range(n):

        j = i + d

        k = j + d

        if k >= n:

            break

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

            ans -= 1



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

s = eval(input())

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

for i in range(n):

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

        k = j-i+j

        if k >= n:

            break

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

            ans -= 1



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

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

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