#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    int N; cin>>N;
    string S; cin>>S;
    int nR=0,nG=0,nB=0;
    for(int i=0;i<N;i++){
        if(S[i]=='R')nR++;
        else if(S[i]=='G')nG++;
        else nB++;
    }

    int ans=nR*nG*nB;
    for(int i=0;i<N;i++){
        for(int j=i+2;j<N;j+=2){
            int k=(i+j)/2;
            if(S[i]!=S[j]&&S[i]!=S[k]&&S[j]!=S[k])ans--;
        }
    }
    cout<<ans;
    return 0;
}