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 = 2*j-i

        if k<n:

            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-2):

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

        k = 2*j-i

        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 = 2 * j - i
        if k < n:
            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 - 2):
    for j in range(i + 1, (n - 1 + i) // 2 + 1):
        k = 2 * j - i
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
print(ans)

-for i in range(n): -    for j in range(i + 1, n): +for i in range(n - 2): +    for j in range(i + 1, (n - 1 + i) // 2 + 1): -        if k < n: -            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]: -                ans -= 1 +        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]: +            ans -= 1