#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 string s;
 cin>>n>>s;
 ll r=0,g=0,b=0;
 for(ll i=0;i<n;i++){
  if( s[i] == 'R' ){
   r++;
  }else if( s[i] == 'G' ){
   g++;
  }else{
   b++;
  }
 }
 ll ans = r*g*b;

 for(ll i=1;i<=n/2;i++){
  for(ll j=0;j<n;j++){
   if( 2*i+j<n ){
    if( s[j] == s[i+j] || s[j] == s[j+2*i] || s[i+j] == s[j+i*2] ){

    }else{
     ans--;
    }
   }else{
    break;
   }
  }
 }
 cout<<ans<<endl;

    return 0;
}
