
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;

  int r=0, g=0, b=0;
  rep(i,n) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'G') {
      g++;
    } else {
      b++;
    }
  }

  ll count = r*g*b;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = 2*j - i;
      if (k >= n || k <= j) continue;
      if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) {
        count--;
      }
    }
  }

  cout << count << endl;
}
