#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	long long r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r++;
		}
		else if (s[i] == 'G') {
			g++;
		}
		else {
			b++;
		}
	}
	long long co = 0;
	for (int j = 0; j < n; j++) {
		for (int k = j + 1; k < n; k++) {
			if (k + k - j >= n) {
				continue;
			}
			else {
				if (s[j] != s[k] && s[j] != s[k + k - j] && s[k] != s[k + k - j]) {
					co++;
				}
			}
		}
	}
	cout << r * g * b - co << endl;
	return 0;
}