#include <bits/stdc++.h>

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long n, ans = 0;
    string s;
    cin >> n >> s;
    int sr = 0;
    int sg = 0;
    int sb = 0;
    REP(i, n) {
        if (s[i] == 'R') {
            sr++;
        }
        if (s[i] == 'G') {
            sg++;
        }
        if (s[i] == 'B') {
            sb++;
        }
    }
    REP(i, n) {
        int sr1 = 0;
        int sg1 = 0;
        int sb1 = 0;
        if (s[i] == 'R') {
            int ms = 0;
            for (int j = 0; j < i; j++) {
                if (s[j] == 'G') {
                    sg1++;
                }
                if (s[j] == 'B') {
                    sb1++;
                }
            }
            ans += sg1 * (sb - sb1);
            ans += sb1 * (sg - sg1);
            for (int j = 1; j <= i; j++) {
                if (i + j < n && (s[i + j] != s[i] && s[i - j] != s[i]) && (s[i + j] != s[i - j])) {
                    ms++;
                }
            }
            ans -= ms;
        }
        if (s[i] == 'G') {
            int ms = 0;
            for (int j = 0; j < i; j++) {
                if (s[j] == 'R') {
                    sr1++;
                }
                if (s[j] == 'B') {
                    sb1++;
                }
            }
            ans += sr1 * (sb - sb1);
            ans += sb1 * (sr - sr1);
            for (int j = 1; j <= i; j++) {
                if (i + j < n && (s[i + j] != s[i] && s[i - j] != s[i]) && (s[i + j] != s[i - j])) {
                    ms++;
                }
            }
            ans -= ms;
        }
        if (s[i] == 'B') {
            int ms = 0;
            for (int j = 0; j < i; j++) {
                if (s[j] == 'G') {
                    sg1++;
                }
                if (s[j] == 'R') {
                    sr1++;
                }
            }
            ans += sr1 * (sg - sg1);
            ans += sg1 * (sr - sr1);
            for (int j = 1; j <= i; j++) {
                if (i + j < n && (s[i + j] != s[i] && s[i - j] != s[i]) && (s[i + j] != s[i - j])) {
                    ms++;
                }
            }
            ans -= ms;
        }
    }
    cout << ans << endl;
}