#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r = 0, g = 0, b = 0, res;
    for(auto el : s){
        if(el == 'R'){
            ++r;
        }else if(el == 'G'){
            ++g;
        }else{
            ++b;
        }
    }
    res = r*g*b;
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < i; ++j){
            if((i-j-2)%2 == 0){
                int k = (i+j)/2;
                if(s[j] != s[k] and s[j] != s[i] and s[i] != s[k]){
                    --res;
                }
            }
        }
    }
    cout << res;
}