/*
 * FileName:     D
 * CreatedDate:  2020-04-12 22:07:32 +0900
 * LastModified: 2020-04-12 22:27:36 +0900
 */

#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    int r_c=0,g_c=0,b_c=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r_c++;
        }
        else if(s[i]=='G'){
            g_c++;
        }
        else{
            b_c++;
        }
    }
    int all_c=r_c*g_c*b_c;
//    printf("%d\n",r_c*g_c*b_c);
    for(int i=0;i<n;i++){
        for(int loop=1;i+2*loop<n;loop++){
//            printf("%c,%c,%c\n",s[i],s[i+loop],s[i+2*loop]);
            if( (int)s[i]+(int)s[i+loop]+(int)s[i+2*loop]==219 ){
                all_c--;
            }
        }
    }
    printf("%d\n",all_c);
    return 0;
}
