#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
// warning: pragmas don't work on USACO and just set to O0

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table<T, U, chash>;
#include <ext/pb_ds/tree_policy.hpp>     //tree<T, U, cmp, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std; using namespace __gnu_pbds;
// shorter template (CF specialization, because compile time better)

inline int RAND(int l, int r) {
    mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> unifd(l, r); return unifd(mt);
}

template <class T> using pq = priority_queue<T, vector<T>, greater<T>>;
using ll = long long; using db = double; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; 
using vll = vector<ll>; const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};

#define ff first
#define ss second
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define pf push_front

//#define TC
const ll INF = 1e18; const db EPS = 1e-8;
const int MOD = 1e9 + 7, // 998244353
    _ = 2e5 + 5;

void solve() {
    int n;
    cin>>n;
    vll a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(all(a));
    ll ans = 1;
    for(int i=1;i<n;i++) {
        ll res = (a[i]-a[i-1]+1);
        ans *= res;
        ans%=MOD;
    }

    ans *= (a[0]+1);
    ans%=MOD;
    cout<<ans;
    
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0); //cout << setprecision(3) << fixed << showpoint;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
//#define double long double
ll binpow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res = res * a % M;
		a = a * a % M;
		b>>=1;
	}
	return res;
}
#define int long long
void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	re(a);
	sort(td(a));
	a.resize(distance(a.begin(), unique(td(a))));
	ll ans = a[0];
	while(true){
		bool ok = false;
		for(int i=n-1;i>=0;i--){
			if(a[i] % ans != 0){
				ans = a[i] % ans;
				ok = true;
			}
		}
		if(!ok) break;
	}
	cout << ans << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //freopen("jump.in", "r", stdin);
	//freopen("equal.out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}