#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

char s[4002];

int main(void){
	uint32_t n=nextpint();
	nextstr(s+1);
	uint32_t dr=0, dg=0, db=0;
	for(uint32_t i=1; i<=n; i++){
		if(s[i]=='R'){
			dr++;
		}else if(s[i]=='G'){
			dg++;
		}else{
			db++;
		}
	}
	uint32_t ans=dr*dg*db;
	for(uint32_t i=1; i<=n/2; i++){
		for(uint32_t j=i-1; j>0; j--){
			if(s[i-j]!=s[i] && s[i+j]!=s[i] && s[i-j]!=s[i+j]){
				ans--;
			}
		}
	}
	for(uint32_t i=n/2+1; i<=n; i++){
		for(uint32_t j=n-i; j>0; j--){
			if(s[i-j]!=s[i] && s[i+j]!=s[i] && s[i-j]!=s[i+j]){
				ans--;
			}
		}
	}
	printf("%"PRIu32"\n", ans);
}
