#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
    int n;
    string s;
    cin >> n >> s;

    int r=0,g=0,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;
    // cout << ans << endl;

    ll ng=0;

    for(int j=0;j<n;j++){
		    for(int i=0;i<j;i++){
                ll k = 2*j-i;
                if((s[i]!=s[j])&&(s[j]!=s[k])&&(s[k]!=s[i])&&(k<n)){
                    ng++;
                }
            }
        }

    cout << ans - ng << endl;
}