#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define x1 first
#define y1 second
#define frb(i,a,b) for(ll (i)=(a);(i) <= (b); (i)+=(i)&-(i))
#define rfrb(i,a) for(ll (i)=(a);(i) > 0;(i)-=(i)&-(i))
#define fr(i,a,b) for(ll (i) = (a); (i) <= (b); (i)++)
#define rep(i,c) for(auto (i) : (c))
#define mini(a,b) ((a) < (b)) ? (a) : (b)
#define maxi(a,b) ((a) > (b)) ? (a) : (b)
#define par pair<ll,ll>
#define vp vector<par>
#define vi vector<ll>

const ll mod = 1e9+7;
ll n;
vi g;
map<ll,ll>ar;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.setf(ios::fixed);cout.precision(0);
    cin>>n;
    ll a;
    g.push_back(0);
    fr(i,1,n){
        cin>>a;
        ar[a]++;
        if(ar[a]==1)g.push_back(a);
    }
    sort(g.begin(),g.end());
    ll id = 0,sol=1;
    rep(v,g){
        sol = ((v-id+1)*(sol))%mod;
        sol%=mod;
        id = v;
    }
    cout<<sol;
    return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;

	vector<ll> A(N);	
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	ll ans = A[0]+1;
	for (int i = 0; i < N-1; ++i) {
		ll dif = A[i+1]-A[i]+1;
		ans = (ans * dif) % MOD;
	}

	cout << ans << "\n";


	return 0;
}
