#include <bits/stdc++.h>
using namespace std;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int RGB[3] = {0, 0, 0};
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            RGB[0]++;
        } else if (S[i] =='G') {
            RGB[1]++;
        } else {
            RGB[2]++;
        }
    }
    int pat = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < N; j++) {
            if (0 <= i-j && i+j < N && S[i-j] != S[i] && S[i] != S[i+j] && S[i+j] != S[i-j]) {
                pat++;
            }
        }
    }
    cout << (long long)RGB[0] * RGB[1] * RGB[2] - pat << endl;
}
