#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long 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++;
        }
    }
    long long ans = r * g * b;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if((j-i)%2 == 0){
                int ave = (i+j)/2;
                if((s[i] != s[j] && s[i] != s[ave]) && s[j] != s[ave]){
                    ans --;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



