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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int g =0;
	int r =0;
	int b =0;
	int ans=0;
	for(int i=0; i<n;i++){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	ans = r * g * b;
	int tmp =0;
	for(int i=0; i< n; i++){
		for(int j=i+1; j < n; j++){
			int k = 2*j-i;
			if(k>=n) continue;
			if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) tmp++;
		}
	}
	cout << ans - tmp << endl;
	return 0;
}
