#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int n; cin >> n;
    string s; cin >> s;

    int r = 0, g = 0, b = 0;
    for(auto i : s) {
        if(i == 'R') r++;
        else if(i == 'G') g++;
        else b++;
    }

    int ans = r * g * b;

    for(int i = 0; i < n; ++i) {
        // 同間隔で条件を満たすなら除く
        for(int d = 0; d < n; ++d) {
            int j = i+d;
            int k = j+d;

            if(k >= n) break;

            if(s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) --ans;
        }
    }

    cout << ans;
}