#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i,j;
  long long int count,r=0,g=0,b=0;
  scanf("%d ",&n);
  char s[4010];
  for(i=0;i<n;i++){
    scanf("%c",&s[i]);
    if(s[i]=='R')
      r++;
    else if(s[i]=='G')
      g++;
    else
      b++;
  }
  count=r*g*b;
  for(i=0;i<n;i++){
    j=1;
    while(i+j+j<n){
      if(s[i]!=s[j+i] && s[j+i]!=s[j+j+i] && s[i]!=s[j+j+i])
        count-=1;
      j+=1;
    }
  }
  printf("%lld\n",count);
  return 0;
}
