#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define ff first
#define ss second

const double pi=3.1415926535897932384626433832795;
const int inf=1e9;
const ll inf2=1e18;
const int mod=1e9+7;

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
    int n;
    cin>>n;
    vi arr(n);
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(all(arr),greater<int>());
    arr.pb(0);
    ll lst=1,cur;
    n++;
    fr(i,1,n){
        cur=(lst*(arr[i-1]-arr[i]+1LL))%mod;
        lst=cur;
    }
    cout<<lst<<endl;
    return;
}

int main()
{
    boost();
    
    int tc=1;
    //cin>>tc;
    while(tc--)
        solve();
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n;++i) {
        cout << (i*2+1)%n+1 << " " << (i*2+2)%n+1 << newl;
    }
}