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


#define ll long long
#define ld long double


#define lop(n) for(ll i=0;i<n;i++)
#define loop(a,b) for(ll i=a;i<b;i++)

#define sortt(x) sort(x.begin(),x.end())

#define MOD 1000000007
#define en "\n"


#define F first
#define S second


#define inputlist for(ll i=0;i<n;i++) cin>>A[i]
#define pb(x) push_back(x)
#define MP make_pair
#define PI 3.14159265

void solve()
{
    ll n;
    cin>>n;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        ll a;cin>>a;mp[a]++;
    }
    vector<ll> vec;
    for(auto itr:mp)
        vec.pb(itr.F);
    ll ans = 1;
    n=vec.size();
    for(ll i=n-1;i>0;i--)
    {
        ans = (ans + ((vec[i]-vec[i-1])*ans)%MOD )%MOD;
    }
    ans = (ans + (vec[0]*ans)%MOD )%MOD;
    cout<<ans;
}


//536870912

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin>>s;
    //call();
    // fac[0] = 1;
    // for (int i = 1; i <= 200005; i++)
    //     fac[i] = (fac[i - 1] * i) % MOD;
    ll t=1;
    
    // cin>>t;
    for(ll i=1;i<=t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
//#pra gma G CC opti mize(3)
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x ) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
ll n,a[114514],ans=1;
int main() {
	read(n);F(i,1,n)read(a[i]);sort(a+1,a+n+1);
	F(i,1,n)ans=ans*(a[i]-a[i-1]+1)%1000000007;
	write(ans);
	return 0;
}
