#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int,int> pii;
#define ALL(x) x.begin(),x.end()
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define FORD(i,a,n) for(ll i=n-1;i>=a;i--)
#define SIZE(x) ll(x.size())
#define F first
#define S second
#define __lcm(a,b) (ll(a)/__gcd(ll(a),ll(b)))*ll(b)

int main() {
    int n;
    cin >> n;
    vi x(n);
    REP(i,n)
    cin >> x[i];
    vi p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    ll ans = pow(2,60);
    for (int i=0;i<(1<<15);i++) {
        vi v(n,0);
        ll c = 0;
        ll a = 1;
        for (int j=0;j<15;j++) {
            if (i & 1<<j) {
                a *= p[j];
                REP(k,n) {
                    if(x[k]%p[j]==0) {
                        v[k]++;
                        if (v[k]==1)
                        c++;
                    }
                }
            }
        }
        if (c==n) {
            if (ans>a)
            ans = a;
        }
    }
    cout << ans;
}
#include<iostream>
#include<vector>
#include<chrono>

#define int long long
#define fi first
#define se second

using namespace std;

//const int MAXN = 100005;
const int MOD = 1e9 + 7;
//const int INF = 1e18;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base :: sync_with_stdio(0);
    int n;
    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    int p[n + 1];
    p[0] = 1;
    for (int i = 1; i <= n; i++) {
        p[i] = p[i - 1] * 2 % MOD;
    }
    int dp[n][2];
    dp[0][0] = t[0];
    dp[0][1] = 0;
    int a = 1, b = 0;
    for (int i = 1; i < n; i++) {
        int c = (a + b) % MOD;
        b = a;
        a = c;
        dp[i][0] = (3 * MOD + dp[i - 1][0] + dp[i - 1][1] + t[i] * a % MOD) % MOD;
        dp[i][1] = (2 * MOD + dp[i - 1][0] - t[i] * b % MOD) % MOD;
    }
    cout << (dp[n - 1][0] + dp[n - 1][1]) % MOD;
    return 0;
}
