n = int(eval(input()))

s = eval(input())

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

for i in range(n-2):

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

        if s[i] == s[j]:

            continue

        k = j - i + j

        if k > n-1:

            continue

        if s[i] == s[k] or s[j] == s[k]:

                continue

        cnt -= 1

print(cnt)

n = int(eval(input()))

s = eval(input())

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

for i in range(n-2):

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

        if s[i] == s[j]:

            continue

        k = j - i + j

        if k > n-1:

            break

        if s[i] == s[k] or s[j] == s[k]:

                continue

        cnt -= 1

print(cnt)

n = int(eval(input()))
s = eval(input())
cnt = s.count("R") * s.count("G") * s.count("B")
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if s[i] == s[j]:
            continue
        k = j - i + j
        if k > n - 1:
            continue
        if s[i] == s[k] or s[j] == s[k]:
            continue
        cnt -= 1
print(cnt)

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

-            continue +            break