#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
  int n,i,j,k;
  char s[4006];
  int cnt = 0;
  int g = 0;
  int b = 0;
  int r = 0;

  scanf("%d", &n);
  scanf("%s", s);

  for(i = 0;i < n;i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'B') b++;
    if(s[i] == 'G') g++;
  }

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      k = 2*j - i;
      if(k < n && s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) cnt++;
    }
  }

  printf("%d\n", r*b*g - cnt);

  return 0;
}
