#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char s[4040];
int cnt = 0;

int main()
{
    int n;
    scanf("%d",&n);
    int r = 0, g = 0, b = 0;
    long long cnt  = 0;

    scanf("%s",s +1);
    for(int i = 1; i <=n; i++)
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    for(int i = 1; i <=n ;i++)
    for(int j = i+1; j <=n; j++){
        int k = 2 *j  - i;
        if(k <= n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k] )
            cnt++;
    }
    printf("%lld",1ll*r*g*b - cnt);

    return 0;
}
