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

int main() {
  int i,j,k,n;
  int Rcount = 0;
  int Gcount = 0;
  int Bcount = 0;
  int count = 0;
  char moji[4000];
  scanf("%d",&n);
  scanf("%s",moji);
  for(i = 0;i < n;i++) {
    if(moji[i]=='R' ) {
      Rcount++;
    } else if(moji[i]=='G') {
      Gcount++;
    } else if(moji[i]=='B') {
      Bcount++;
    }
  }
  for(i = 0;i < n;i++) {
    for(j = 0;j < n;j++) {
      for(k = 0;k < n;k++) {
        if(j-i == k-j) {
          count++;
        }
      }
    }
  }
  printf("%d",count-(Rcount*Gcount*Bcount));
}
