#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

//エラストテネスの篩(O(nloglogn))
struct sieve {
    int n;
    vector<int> f, primes;
    sieve(int n = 1) : n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    bool is_prime(int x) {return f[x] == x;}
    // 素因数分解したものを返す(12=2x2x3)
    vector<int> factor_list(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    // xが小さいときはエラストテネスの篩を用いて素因数分解
    vector<P> factor(int x) {
        vector<int> fl = factor_list(x);
        if (fl.size() == 0) return {};
        vector<P> res(1,P(fl[0],0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p,1);
            }
        }
        return res;
    }
    vector<pair<ll,int>> factor(ll x) {
        vector<pair<ll,int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) {
                x /= p;
                y++;
            }
            if (y != 0) res.emplace_back(p,y);
        }
        if (x != 1) res.emplace_back(x,1);
        return res;
    }
};

ll gcd(ll a, ll b) {return(b ? gcd(b, a % b) : a);}

int main() {
    int n; cin >> n;
    vint x(n);
    rep(i,n) cin >> x[i];
    vint primes;
    sieve sv(55);
    for (int v = 1; v <= 50; v++) if (sv.is_prime(v)) primes.emplace_back(v);
    int sz = primes.size();
    ll ans = inf_l;
    rep(i,1<<sz) {
        ll ans_tmp = 1;
        bool ok = true;
        rep(j,sz) if (i >> j & 1) ans_tmp *= primes[j];
        rep(j,n) {
            if (gcd(x[j], ans_tmp) == 1) ok = false;
        }
        if (ok) ans = min(ans, ans_tmp);
    }
    cout << ans << endl;
}
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}










int main(){
    std::string S; std::cin >> S;
    std::reverse(std::begin(S), std::end(S));
    char prv(0);
    int prvidx(0);
    std::vector<int> cnt(26);
    ++cnt[S[0]- 'a'];
    long long ans(0);
    for(int i(1), i_len(S.length()); i < i_len; ++i){
        if(S[i] == S[i-1]){
            if(prv == S[i]){
                ans += i - prvidx - cnt[S[i] - 'a'] - 1;
            }else{
                ans += i - cnt[S[i] - 'a'];
            }
            prv = S[i];
            prvidx = i;
            for(int j(0); j < 26; ++j) cnt[j] = 0;
        }else{
            ++cnt[S[i] - 'a'];
        }
    }
    std::cout << ans << std::endl;
    return 0;
}
