n = int(eval(input()))

s = eval(input())

r = s.count("R")

g = s.count("G")

b = s.count("B")

c = 0

for i in range(n):

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

        if len(set([s[i],s[i+j],s[i+j+j]])) == 3:

            c += 1

print(((r*g*b) - c))
n = int(eval(input()))

s = list(eval(input()))

r = s.count("R")

g = s.count("G")

b = s.count("B")

c = 0

for i in range(n):

    j = 1

    while i+j+j+1 <= n:

        if  len(set([s[i],s[i+j],s[i+j+j]]))==3:

            c += 1

        j += 1

print((r*g*b - c))
n = int(eval(input()))
s = eval(input())
r = s.count("R")
g = s.count("G")
b = s.count("B")
c = 0
for i in range(n):
    for j in range(1, int((n - i - 1) / 2) + 1):
        if len(set([s[i], s[i + j], s[i + j + j]])) == 3:
            c += 1
print(((r * g * b) - c))

n = int(eval(input()))
s = list(eval(input()))
r = s.count("R")
g = s.count("G")
b = s.count("B")
c = 0
for i in range(n):
    j = 1
    while i + j + j + 1 <= n:
        if len(set([s[i], s[i + j], s[i + j + j]])) == 3:
            c += 1
        j += 1
print((r * g * b - c))

-s = eval(input()) +s = list(eval(input())) -    for j in range(1, int((n - i - 1) / 2) + 1): +    j = 1 +    while i + j + j + 1 <= n: -print(((r * g * b) - c)) +        j += 1 +print((r * g * b - c))