#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  char s[n+1];
  scanf("%s", s);

  long r = 0;
  long g = 0;
  long b = 0;

  long count = 0;

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

  for (long i = 0; i < n; i++) {
    for (long j = i+1; j < n; j++) {
      if (s[j] == s[i]) {
        continue;
      }
      if (j*2-i >= n) {
        continue;
      }
      if (s[j*2-i] != s[i] && s[j*2-i] != s[j]) {
        count++;
      }
    }
  }

  long answer = r*g*b-count;

  printf("%ld\n", answer);

  return 0;
}