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

int main () {
  int n;
  string s;
  cin >> n >> s;
  long long ans = 0;
  int r = 0, g = 0, b = 0;
  
  for(char c : s) {
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }
  ans = r * g * b;
  
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n ; ++j) {
      if (i - j < 0 || i + j >= n) continue;
      if (s[i] != s[i+j] && s[i] != s[i-j] && s[i+j] != s[i-j]) ans--;
    }
  }
  cout << ans;
}
      
