#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>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
// const int MOD = 998244353;
struct mint {
	ll x;
	mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
	mint operator-() { return mint(-x); }
	mint operator+=(mint rhs) {
		x += rhs.x;
		if (x >= MOD) x -= MOD;
		return *this;
	}
	mint operator-=(mint rhs) {
		x -= rhs.x;
		if (x < 0) x += MOD;
		return *this;
	}
	mint operator*=(mint rhs) {
		x = x * rhs.x % MOD;
		return *this;
	}
	mint operator+(mint rhs) { return mint(*this) += rhs; }
	mint operator-(mint rhs) { return mint(*this) -= rhs; }
	mint operator*(mint rhs) { return mint(*this) *= rhs; }
	mint pow(ll n) {
		mint r = 1;
		for (mint t = (*this); n; t *= t, n >>= 1)
			if (n & 1) r *= t;
		return r;
	}
	mint inv() { return (*this).pow(MOD - 2); }
	mint operator/=(mint rhs) { return *this *= rhs.inv(); }
	mint operator/(mint rhs) { return mint(*this) /= rhs; }
};
ostream &operator<<(ostream &os, const mint &dt) {
	os << dt.x;
	return os;
}
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	set<int> s;
	for (int i = 0; i < n; i++) {
		s.insert(a[i]);
	}
	mint ans = 1;
	int pre = 0;
	for (auto v : s) {
		ans *= v - pre + 1;
		pre = v;
	}
	cout << ans << endl;
	return 0;
}