#include<bits/stdc++.h>

using namespace std;

long long n, r, g, b, m;
string s;

int main(){
	cin >> n >> s;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	m = r*g*b;
	for(int i = 0; i < n; ++i){
		for(int j = 1; i+j+j < n; ++j){
			if(s[i]!=s[i+j]&&s[i]!=s[i+j+j]&&s[i+j]!=s[i+j+j]) m--;
		}
	}
	cout << m << endl;
}