#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  string b;
  cin>>b;
  int c=0,d=0,e=0;
  rep(i,a){
  if(b[i]=='R')
    c++;
  else if(b[i]=='G')
    d++;
  else
    e++;
  }int m=0;
  for(int i=1;i<=(a-1)/2;i++){
    for(int j=0;j<=a-1-2*i;j++){
      if(b[j]!=b[i+j]&&b[i+j]!=b[2*i+j]&&b[2*i+j]!=b[j])
         m++;
    }
    }
    cout<<c*d*e-m<<endl;
}
