#include <stdio.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  long i, j, n, r=0, g=0, b=0, ans;
  scanf("%ld",&n);
  char s[n];
  scanf("%s",s);
  rep(i,n){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ans = r*g*b;
  rep(i,n-1){
    for(j=i+1;j<(i+n+1)/2;j++){
      if(s[2*j-i]!=s[i]&&s[2*j-i]!=s[j]&&s[i]!=s[j]) ans--;
    }
  }
  printf("%ld",ans);
}