#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0, g = 0, b = 0;
  for(int i = 0; i < n; ++i){
    if(s[i] == 'R') r++;
    else if(s[i] == 'G') g++;
    else b++;
  }
  int ans = r * g * b;
  for(int i = 0; i < n; ++i){
    for(int j = 1; j < n ; ++j){
      if(i - j < 0 || i + j >=n) continue;
      if(s[i] != s[i + j] && s[i - j] != s[i] && s[i - j] != s[i + j]) ans--;
    }
  }
  cout << ans << endl;
}