#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    ll count[3] = {};
    for(int i = 0;i < n;i++)
    {
        if(s[i] == 'R')
        {
            count[0]++;
        }
        else if(s[i] == 'G')
        {
            count[1]++;
        }
        else
        {
            count[2]++;
        }
    }
    ll ans = count[0] * count[1] * count[2];
    for(int i = 1;i + 1 < n;i++)
    {
        for(int j = 1;i + j < n && i - j >= 0;j++)
        {
            if(s[i] != s[i - j] && s[i] != s[i + j] && s[i - j] != s[i + j])
            {
                ans--;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}