/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define int    long long
#define double    long double
#define uint   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
int google_itr = 1;
#define google(x) cout<<"Case #"<<x<<": "
#define pi 3.14159265358979323846264338327950L

const int mod = 1e9+7;
const int inf = 1e18;


void virus(){

          int len;
          cin >> len;

          string seq;
          cin >> seq;

          int ans = 0;
          for(auto i=0; i<len; i++){
              int a = 0, b = 0;
              for(auto j=i; j<len; j++){
                  if(seq[j] == 'A') a++;
                  if(seq[j] == 'T') a--;
                  if(seq[j] == 'C') b++;
                  if(seq[j] == 'G') b--;
                  if(!a and !b) ans++;
              }
          }
          
          cout << ans << endl;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    int t = 1;
    //cin >> t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}
//------------ヘッダーインクルード------------
#include <stdio.h>
#include <cmath>
#include <stdarg.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
//#include <pair>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
//------------型マクロ定義------------
typedef long l;
typedef long long ll;
#define INIF 1e9;
#define MOD 1000000007;
#define ALL(v) (v).begin(), (v).end()
//------------vectorマクロ定義------------
#define v(Type) vector<Type>
#define vv(Type) vector<vector<Type>>
#define vvv(Type) vector<vector<vector<Type>>>
#define vini(n, m) ((n), (m))
//------------forマクロ定義------------
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define rep2(i, m, n) for(int i = (m); (i) < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define fe(i, STL) for(auto i: (STL))
//------------ioマクロ定義------------
#define co cout<<
#define en <<endl
#define br co "" en
#define pr(value) ","<<#value<<": "<<value
#define sn(value) #value,value

template<class Type>
void print_value(string name, Type value){co name << ":" << value;}
#define pri(value) print_value(sn(value))

template<class Type>
void print_value2(string name, Type value){
  int num = 0;
  fe(i, value)co name << "[" << num++ << "]:"  << i << ", ";
}
#define pri2(Type, value) print_value2<Type>(sn(value))
//------------main------------

int main(){
  int N;
  cin >> N;
  long long int che = 0, man = 0, input;
  long double eu = 0.0;
  
  rep(i, N){
    cin >> input;
    man += abs(input);
    eu += (input * input);
    if(che < abs(input))che = abs(input);
  }
  eu = sqrt(eu);
  
  co man en;
  co fixed << setprecision(15) << eu en;
  co che en;
  
  return 0;
}