#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int r, g, b,n;
string s;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    f(i,0,n){
        if(s[i] == 'R'){
            r++;
        }
        else if(s[i] == 'G'){
            g++;
        }
        else
            b++;
    }
    int ans = r*g*b;
    f(i,0,n){
        f(j,1,n){
            int l = i-j;
            int rr = i+j;
            if(l >= 0 and l < n and rr >= 0 and rr < n and s[l] != s[i] and s[rr] != s[i] and s[l] != s[rr]){
                ans --;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
 