#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  vector<ll>cnt(3);
  rep(i,n){
    if(s[i]=='R') cnt[0]++;
    if(s[i]=='G') cnt[1]++;
    if(s[i]=='B') cnt[2]++;
  }
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  
  rep(j,n) rep(i,j){
    ll k = j + j - i;
    if(k<n){
      if(s[i]==s[j]) continue;
      if(s[i]==s[k]) continue;
      if(s[k]==s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}
