n = int(eval(input()))

s = eval(input())

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

for j in range(n):

    for i in range(j):

        k = j+(j-i)

        if k < n:

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

                continue

            ans -= 1



print(ans)


def main():

    n = int(eval(input()))

    s = eval(input())

    r,g,b = 0,0,0

    for i in s:

        if i == 'R': r += 1

        elif i == 'G': g += 1

        elif i == 'B': b += 1

    ans = r*g*b

    for j in range(n):

        for i in range(j):

            k = j+(j-i)

            if k < n:

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

                    continue

                ans -= 1

    print(ans)

if __name__ == "__main__":

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

def main():
    n = int(eval(input()))
    s = eval(input())
    r, g, b = 0, 0, 0
    for i in s:
        if i == "R":
            r += 1
        elif i == "G":
            g += 1
        elif i == "B":
            b += 1
    ans = r * g * b
    for j in range(n):
        for i in range(j):
            k = j + (j - i)
            if k < n:
                if s[i] == s[j] or s[i] == s[k] or s[k] == s[j]:
                    continue
                ans -= 1
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -s = eval(input()) -ans = s.count("R") * s.count("G") * s.count("B") -for j in range(n): -    for i in range(j): -        k = j + (j - i) -        if k < n: -            if s[i] == s[j] or s[i] == s[k] or s[k] == s[j]: -                continue -            ans -= 1 -print(ans) +def main(): +    n = int(eval(input())) +    s = eval(input()) +    r, g, b = 0, 0, 0 +    for i in s: +        if i == "R": +            r += 1 +        elif i == "G": +            g += 1 +        elif i == "B": +            b += 1 +    ans = r * g * b +    for j in range(n): +        for i in range(j): +            k = j + (j - i) +            if k < n: +                if s[i] == s[j] or s[i] == s[k] or s[k] == s[j]: +                    continue +                ans -= 1 +    print(ans) + + +if __name__ == "__main__": +    main()