n = int(eval(input()))

s = eval(input())

r = []

g = []

b = []



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 and s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:

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

    si = s[i]

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

        sj = s[j]

        k = 2*j-i

        if k < n and s[k] != si and s[k] != sj and si != sj:

            ans -= 1



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

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