#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using ll = long long;
using lint = long long;
typedef vector<long long> vint;
typedef pair<long long, long long> pint;
#define INF INT32_MAX / 2
#define INF64 INT64_MAX / 2
#define EPS 0.001
#define EPS14  1.0E-14
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define c(n) cout<<n<<endl;
#define cf(n) cout<<fixed<<setprecision(15)<<n<<endl;
template <class T>inline bool chmin(T&a,T b) {if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T&a,T b) {if(a<b){a=b;return true;}return false;}
template<class T>inline T sum(T n){return n*(n+1)/2;}
map<ll,ll> prime_fac(ll A) {map<ll,ll>mp;for(ll i=2;i*i<=A;i++){while(A%i== 0){mp[i]++;A/=i;}}if(A!=1){mp[A]=1;}return mp;}
bool is_prime(ll N){if(N<=1)return false;for(ll i=2;i*i<=N;i++){if(N%i==0) return false;}return true;}
template<class T>inline T myceil(T a,T b){return (a+(b-1))/b;}
bool is_product_overflow(long long a,long long b) {long prod=a*b;return (prod/b!=a);}


void solve(long long N, std::string S){
    ll ans = 0;
    REP (i, N) {
        vector<ll> mp(10000, 0);
        for (int j = i; j < N; j++) {
            mp[S[j]]++;
            if (mp['A'] == mp['T'] && mp['G'] == mp['C']) ans++;
        }
    }
    c(ans)
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=55;
int n,vis;
int a[maxn],prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
bool s[maxn][15];
inline int read(){
	int ret=0,f=1;	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while(isdigit(ch)){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
signed main(){
	n=read();
	for(int k=1;k<=n;k++)   a[k]=read();
	int ans=0;
	for(int k=0;k<(1<<15);k++){
		int sum=1;
		vis=0;
		for(int j=0;j<15;j++){
			int p=1ll<<j,x=prime[j];
			if(!(k&p))  continue;
			sum*=x;
			for(int i=1;i<=n;i++)
			if(gcd(x,a[i])>1) vis|=1ll<<i-1;
		}
		if(vis==(1ll<<n)-1){
			if(!ans)    ans=sum;			else    	ans=min(ans,sum);
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
10
2 5 7 12 27 8 18 33 13 32
*/