#include "bits/stdc++.h"
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int                      long long
#define ll                       long long
#define ld                       long double
#define ull                      unsigned long long
#define vi                       vector<int>
#define pii                      pair<int,int>
#define pqbig                    priority_queue<int>
#define pqsmall                  priority_queue<int,vi,greater<int> >
#define mod                      1000000007 //998244353

#define for0(i,n)                for(int i=0;i<n;++i)
#define fora(i,a,b)              for(int i=a;i<=b;++i)
#define rfor(i,a,b)              for(int i=a;i>=b;--i)
#define onlyunique(v)            v.erase(unique(all(v)), v.end()); //only for sorted vector
#define rev(v)                   reverse(v.begin(),v.end())

#define sz(x)                    (int)x.size()
#define def(v)                   memset(v, -1, sizeof(v));
#define def0(v)                  memset(v, 0, sizeof(v));
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define first                        first
#define second                        second
#define pb                       push_back
#define mp                       make_pair
#define pie                      (3.141592653589)
#define inf                      ((ll)7000000000000000000)
#define um                       unordered_map
#define ABS(x)                   ((x < 0) ? -x : x )

#define ordered_set             tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}
#else
#define dbg(...) 50
#endif

void operations()
{
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    cout << setprecision(15) << fixed;
}

template<typename T> void uniq(vector<T> &v)
{
    sort(all(v)); v.resize(unique(all(v)) - v.begin());
}

template<typename T> void leftShift(vector<T> &v, ll k)
{
    k %= sz(v);
    if (k < 0) k += sz(v);
    rotate(v.begin(), v.begin() + k, v.end());
}

template<typename T> void rightShift(vector<T> &v, ll k)
{
    leftShift(v, sz(v) - k);
}

template<typename T> vector<T> readVector(int n)
{
    vector<T> res(n);
    for (int i = 0; i < n; i++) cin >> res[i];
    return res;
}

template<typename T> void printVector(vector<T> res)
{
    int n = res.size();
    for (int i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const int N  = 2001;
int parent[N], rank1[N];

void make_set(int v) {
    parent[v] = v;
    rank1[v] = 0;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank1[a] < rank1[b])
            swap(a, b);
        parent[b] = a;
        if (rank1[a] == rank1[b])
            rank1[a]++;
    }
}
void solve()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    vi red, green;
    map<int, bool> blue;

    int i = 0;
    for (auto it : s)
    {
        if (it == 'R')
            red.pb(i);
        else if (it == 'G')
            green.pb(i);
        else
            blue[i] = true;
        i++;
    }

    int sol = sz(red) * sz(green) * blue.size();

    for (auto it : red)
    {
        for (auto it2 : green)
        {
            if (blue[(it + it2) / 2] == true and abs(it - (it + it2) / 2) == abs(it2 - (it + it2) / 2))
            {
                sol--;
            }
            if (blue[it - (it2 - it)])
            {
                sol--;
            }
            if (blue[it2 - (it - it2)])
                sol--;
        }
    }
    cout << sol << endl;
}


signed main()
{
    clock_t t1, t2;
    t1 = clock();
    operations();

    int t = 1;
    //cin >> t;

    while (t--)
    {
        solve();
        // cout << "Case" << " " << "#" << i << ":" << " " << ans << endl;
        // i++;
    }
#ifndef ONLINE_JUDGE
    t2 = clock(); cerr << "time taken : " << (t2 - t1) / (ld)CLOCKS_PER_SEC;
#endif

    return 0;
}


Measured memory_bytes: 4308