#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

LL f(LL X, LL x){
	LL u = max(X, x);
	LL v = min(X, x);
	LL r = u % v;
	if(r == 0) return v;
	return f(v, r);
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N; cin >> N;
	vector<LL> A;
	for(int i=0; i<N; i++){ LL a; cin >> a; A.push_back(a); }
	sort(A.begin(), A.end());
	LL X = A[A.size()-1];
	LL x = A[0];

	if(N == 1){ printf("%lld\n", A[0]); return 0; }
	LL ans = A[0];
	for(int i=1; i<N; i++) ans = f(ans, A[i]);
	printf("%lld\n", ans);
	return 0;
}
#include <bits/stdc++.h> 
using namespace std; 

#define ffor(i, a, b) for (int i = a ; i <= (int) b ; i++) 
#define rfor(i, a, b) for (int i = (int) b ; i >= a ; i--)  

#define vec vector 
#define PB push_back 

#define MP make_pair 
#define MT make_tuple 
#define F first 
#define S second 

using ll = long long int; // watch out for overflows in your code
using pii = pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void debug() { cout << "\n"; };
template <typename T, typename... Targs> 
void debug(T t, Targs... args) {
    cout << t << " ";
    debug(args...);
}

template <typename T1, typename T2> 
inline ostream& operator << (ostream& os, const pair<T1,T2>& p) {
    return os << "(" << p.F << ", " << p.S << ")";
}

template <typename T> 
inline ostream& operator << (ostream& os, const vec<T>& v) {
    for(auto& t : v) {
        os << t << " ";
    }
    return os;
}

template <typename T> 
inline ostream& operator << (ostream& os, const vec<vec<T>>& m) {
    for(auto& v : m) {
        for(auto& t : v) {
            os << t << " ";
        }
        os << "\n";
    }
    return os;
}

template <typename T> 
inline ostream& operator << (ostream& os, const set<T>& v) {
    for(auto& t : v) {
        os << t << " ";
    }
    return os;
}

template <typename K, typename V> 
inline ostream& operator << (ostream& os, const map<K,V>& m) {
    for(auto& p : m) {
        os << p.F << " -> " << p.S << "\n";
    }
    return os;
}

////////////////////////////////////////////////////////////////////////
template <ll mod> 
class modular_int {
    private:
    ll x;

    public:
    modular_int(ll y) : x( (y % mod + mod) % mod) {}
    modular_int() : x(0LL) {}

    ll rpr() const { return x; }

    modular_int<mod>& operator += (const modular_int<mod>& rhs) {
        x = (x + rhs.x) % mod;
        return *this;
    }

    friend modular_int<mod> operator + (modular_int<mod> lhs, const modular_int<mod>& rhs) {
        lhs += rhs;
        return lhs;
    }

    modular_int<mod>& operator *= (const modular_int<mod>& rhs) {
        x = (x * rhs.x) % mod;
        return *this;
    }

    friend modular_int<mod> operator * (modular_int<mod> lhs, const modular_int<mod>& rhs) {
        lhs *= rhs;
        return lhs;
    }

    modular_int<mod>& operator -= (const modular_int<mod>& rhs) {
        x = ((x - rhs.x) % mod + mod) % mod;
        return *this;
    }

    friend modular_int<mod> operator - (modular_int<mod> lhs, const modular_int<mod>& rhs) {
        lhs -= rhs;
        return lhs;
    }
};

const ll MOD = 1e9 + 7;
using mint = modular_int<MOD>;

////////////////////////////////////////////////////////////////////////

int N;
vec<int> A;

map<int, int> m;
void compute_m() {
    sort(A.begin()+1, A.end());
    int cur_h = A[N];
    rfor(i, 1, N) {
        int h = A[i];
        int n = N-i+1;
        if(h < cur_h) {
            m[cur_h] = n-1;
            cur_h = h;
        }
    }
    m[cur_h] = N;
}

vec<ll> g;
void compute_g() {
    auto it = m.rbegin();
    int cur_h = it->F;
    int cur_n = it->S;
    advance(it, 1);

    for(; it != m.rend(); ++it) {
        auto [h, n] = *it;
        g.PB((ll) (cur_h-h));
        cur_h = h;
    }
    g.PB((ll) cur_h);
}

////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;
    A.assign(N+1, 0);
    ffor(i, 1, N) {
        cin >> A[i];
    }

    compute_m();
    compute_g();

    //debug(m);
    //debug(A);
    //debug(g);

    mint ans(1LL);
    for(ll x : g) {
        ans *= mint(x+1LL);
    }
    cout << ans.rpr() << "\n";
}

