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

int main() {
	int N;
	string S;
	cin >> N >> S;
	long long ANS = 0;
	int RS = 0, GS = 0, BS = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') RS++;
		if (S[i] == 'G') GS++;
		if (S[i] == 'B') BS++;
	}
	ANS = RS * GS * BS;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j + i + i < N; j++) {
			if (S[j] != S[i + j] && S[i + j] != S[i + i + j] && S[i + i + j] != S[j]) ANS--;
		}
	}
	cout << ANS << endl;
}