import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp;
  long rc, gc, bc;
  foreach (i; 0..n) {
    if (s[i] == 'R') rc++;
    else if (s[i] == 'G') gc++;
    else bc++;
  }

  auto cnt = rc * gc * bc;
  foreach (int i; 0..n) {
    foreach (int j; i+1..n) {
      if (s[i] == s[j]) continue;
      auto k = 2*j - i;
      if (k >= n) continue;
      if (s[i] == s[k] || s[j] == s[k]) continue;
      cnt--;
    }
  }
  cnt.writeln;
}
