#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)

int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int r = 0,g = 0,b = 0;
    REP(i,N){
        if(S[i]=='R') r++;
        else if(S[i]=='G') g++;
        else b++;
    }
    ll res = r*g*b;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int k = 2*j - i;
            if(j<N){
                if(S[i]==S[j] || S[j]==S[k] || S[k]==S[i]){
                    res--;
                }
            }
        }
    }
    cout << res << endl;
}