#include<stdio.h>

int main(void){
	int N;
	scanf("%d", &N);
	char S[N];
	scanf("%s", S);
	int r = 0, b = 0, g = 0, i,j,x=0;
	for (i = 0; i < N; i++) {
		if (S[i] == 'R') r++;
		else if (S[i] == 'B') b++;
		else if(S[i] == 'G') g++;
	}
	for (j = 1; j + j < N; j++) {
		for (i = 0; i + j + j < N; i++) {
			if (S[i] != S[i + j] && S[i + j] != S[i + j + j] && S[i + j + j] != S[i]) x++;
		}
	}
	printf("%d", r * b * g - x);

	return 0;
}
