#include <bits/stdc++.h>
#define int long long

using namespace std;

const int md = 1000000007;
int n=0;
int a[100001];
set<int> Set;

signed main() {
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> a[i];	
		Set.insert(a[i]);
	}
	int prev = 0;
	int res = 1;
	for (auto s : Set)
	{
		res*=((s-prev+1)%md);
		res%=md;
		prev = s;
	}
	cout << res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,ll>a;
vector<ll>v;
int main()
{
	ios::sync_with_stdio(false);
	ll n,num;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>num;
		if(a[num]==0)v.push_back(num);
		a[num]++;
	}
	ll res=((n-1)*n)/2;
	for(int i=0;i<v.size();i++)
	{
		if(a[v[i]]>1)res-=((a[v[i]]-1+1)*(a[v[i]]-1))/2;
	}
	cout<<res<<endl;
	return 0;
} 