#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	ll sum(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll c(0);
	int crr(0), cgg(0), cbb(0);
	rep(i, n) {
		if (s[i] == 'R') {
			++crr;
		}
		else if (s[i] == 'G') {
			++cgg;
		}
		else {
			++cbb;
		}
	}
	rep(i, n) {
		for(int j=i+1;j<n-1;++j){
			if (2*j-i < n) {
				if (s[i] != s[j] && s[j] != s[2*j-i] && s[2*j-i] != s[i]) {
					++c;
				}
			}
		}
		
	}
	cout << crr*cgg*cbb-c;
	return 0;
}