#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int  main() {
	int n; cin >> n;
	vector<int> a(n);
	
	for (int i = 0; i < n; i++)
		cin >> a[i];

	vector<int>::iterator iter = max_element(a.begin(), a.end());
	int amax = *iter ;

	long long c = 0, ans = 0, psum = 0;
	for (int i = 0; i <n; i++) {
		psum = 0; c = 0;
		for (int j = 0; j < n; j++) {
			if (0<= a[j]-a[i]) {
				c++;
			}
			else {
				psum = c * a[i];
				if (ans < psum)
					ans = psum;
				c = 0;
			}
		}
		if (c == 0)
			psum = a[i];
		else
			psum = c * a[i];
	
		if (ans < psum)
			ans = psum;
	}

	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = pow(10,9)+7;


int main(){
  ll n;
  cin >> n;
  vector<ll> A(n);
  for(ll i=0; i<n; i++) cin >> A[i];
  
  sort(A.begin(),A.end());
  
  ll ans = A[0]+1;
  for(ll i=1; i<n; i++){
    ans*= (A[i]-A[i-1])+1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}