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

int main(){
    int n;
    char s[4000];
    long long int sum = 0;
    scanf("%d",&n);
    scanf("%s",s);
    int rnum = 0;
    int gnum = 0;
    int bnum = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'R'){
            rnum++;
            continue;
        }else if(s[i] == 'G'){
            gnum++;
            continue;
        }else{
            bnum++;
            continue;
        }
    }
    sum = rnum*gnum*bnum;
    for(int i = 1;i < n - 1;i++){
        for(int j = 1;i - j >=0 && i + j < n;j++){
            if(s[i] != s[i - j] && s[i] != s[i + j] && s[i - j] != s[i + j]){
                sum--;
            }
        }
    }
    printf("%lld",sum);
    return 0;
}
