#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, i, j, k, R, G, B;
  R = 0;
  G = 0;
  B = 0;
  string S;
  cin >> N >> S;
  if (N == 1 || N == 2 || N == 3) {
    cout << '0' << endl;
  }
  for (i = 0; i < N; i++) {
    if (S[i] == 'R') {
      R++;
    } else if (S[i] == 'G') {
      G++;
    } else {
      B++;
    }
  }
  int tmp = 0;
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      if (2 * j - i < N) {
        if (S[i] != S[j] && S[j] != S[2 * j - i] && S[2 * j - i] != S[i]) {
          tmp++;
        }
      }
    }
  }
  //   cout << R << G << B << tmp << endl;
  cout << max((R * B * G) - tmp, 0) << endl;
}