#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=100+10;
const int SIZE=50;
ll prime[mx], ptot;
bool isp[mx];
ll x[mx];
ll ans;
ll n;
vector<ll>vec[mx];
void fj(ll v){
    ll cpy=v;
    for(ll i=2;i*i<=v;i++){
        if(v%i==0){
            vec[cpy].push_back(i);
            while(v%i==0)v/=i;
        }
    }
    if(v!=1)vec[cpy].push_back(v);
}
void getPrime(){
    isp[1]=1;
    for(ll i=2;i<=SIZE;i++){
        if(isp[i]==0){
            prime[++ptot]=i;
        }
        for(ll j=1;j<=ptot;j++){
            if(i*prime[j]>SIZE)break;
            isp[i*prime[j]]=1;
            if(i%prime[j]==0)break;
        }
    }
}
bool vis[mx];
void dfs(ll c, ll v){//c<=ptot;
    if(v>=ans) return;
    if(c==ptot+1){
        for(ll i=1;i<=n;i++){
            bool ok=false;
            for(ll j=0;j<vec[x[i]].size();j++){
                ll value=vec[x[i]][j];
                if(vis[value]){
                    ok=true;
                    break;
                }
            }
            if(!ok) return;
        }
        ans=v;
        return;
    }
    vis[prime[c]]=true;
    dfs(c+1, v*prime[c]);
    vis[prime[c]]=false;
    dfs(c+1, v);
}
void solve(){
    getPrime();
    for(ll i=1;i<=SIZE;i++)fj(i);

    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>x[i];
    }
    n=unique(x+1, x+1+n)-x-1;

    ans=1e18+10;
    dfs(1, 1);
    cout<<ans<<endl;
}
int main(){
#ifdef LOCAL
    FILE *fp=freopen("1", "r", stdin);
#endif
    solve();
#ifdef LOCAL
    fclose(fp);
#endif
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long unsigned int ull;
typedef pair<ll, ll> llpair;

typedef std::numeric_limits<double> dbl;

#if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)
#define _MATH_DEFINES_DEFINED
#define M_E 2.71828182845904523536
#define M_LOG2E 1.44269504088896340736
#define M_LOG10E 0.434294481903251827651
#define M_LN2 0.693147180559945309417
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.785398163397448309616
#define M_1_PI 0.318309886183790671538
#define M_2_PI 0.636619772367581343076
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.707106781186547524401
#endif

void prepareIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(dbl::max_digits10);
}

const ll MOD = 1e9 + 7;

const ll N = 3e3 + 1;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    prepareIO();

    ll n;
    cin >> n;

    vector<ll> a(n + 1), psum(n + 1, 0);

    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        psum[i] = psum[i - 1] + a[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    vector<vector<ll>> sum(n + 1, vector<ll>(n + 1, 0));

    sum[1][0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= i; j++)
        {
            dp[i][j] = sum[j][psum[i] % j];
        }

        for (ll k = 1; k <= n; k++)
        {
            sum[k][psum[i] % k] = ((sum[k][psum[i] % k]) % MOD + (dp[i][k - 1]) % MOD) % MOD;
        }
    }

    ll ans = 0;
    for (ll j = 1; j <= n; j++)
    {
        ans = ((ans % MOD) + (dp[n][j] % MOD) % MOD);
    }

    cout << ans << endl;
    return 0;
}