#include <stdio.h>

int main(){
  long int num,sum;
  scanf("%ld",&num);
  char s[num];
  scanf("%s",s,num);
  long int count_r=0,count_g=0,count_b=0;
  for(int a=0;a<=num-1;a++){
    if(s[a]=='R')count_r++;
    else if(s[a]=='G')count_g++;
    else count_b++;
  };
  sum=count_r*count_g*count_b;
  for(int j=0;j<=num-2;j++){
    for(int i=j+1;i<=num-1;i++){
      int k=2*i-j;
      if(k<=num-1&&s[j]!=s[i]&&s[k]!=s[i]&&s[k]!=s[j])
        sum--;
    };
  };
   printf("%ld",sum);
};
            