#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  LL r=0, g=0, b=0;
  rep(i,N){
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }
  LL ans=r*g*b;
  rep(i,N){
    for(int j=i+1; j<N; j++){
      if(j*2-i<N&&S[i]!=S[j]&&S[j]!=S[j*2-i]&&S[i]!=S[j*2-i]) ans--;
    }
  }
  cout << ans << endl;

  return 0;
}
