#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    char S[4000];
    scanf("%s", S, N);
    int i, j, countr = 0, countg = 0, countb = 0;
    long long int ans = 0;
    for(i = 0; i < N; ++i){
        if(S[i] == 'R'){ ++countr; }
        else if(S[i] == 'G'){ ++countg; }
        else{ ++countb; }
    }
    ans = countr * countg * countb;
    for(i = 0; i < N-2; ++i){
        for(j = i+1; 2*j-i < N; ++j){
            if(S[i] != S[j] && S[i] != S[2*j-i] && S[j] != S[2*j-i]){ --ans; }
        }
    }
    printf("%lld\n", ans);
    return 0;
}