#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N >> S;
    int R,G,B;
    R = G = B = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'R') R++;
        else if(S[i] == 'G') G++;
        else B++;
    }
    ll ans = R*G*B;
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            int k = 2*j-i;
            if(k >= N) break;
            if(S[i] != S[j] && S[i] != S[k] && S[k] != S[j]) ans -= 1;
        }
        
    }
    cout << ans << endl;
}