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

#define ll long long int 
#define pb(a) push_back(a)
#define vll vector<ll>
#define loop(i, n) for(ll i=1;i<=n;i++)
#define loop0(i, n) for(ll i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define mp(i, j) make_pair(i, j);
const ll mod = 1000000007;
const ll big = 2999999999999999999;
const ll small = -2999999999999999999;
void in2(ll& a, ll& b) { in(a); in(b); }
void in3(ll& a, ll& b, ll& c) { in(a); in(b); in(c); }
void swap(ll& a, ll& b) { a = a+b; b = a-b; a = a-b; }
void arrayIn(vll& a, ll& n) { loop0(i, n) in(a[i]); }

ll n;
vll a;

int main()
{
  in(n);
  a.resize(n);
  arrayIn(a, n);
  sort(a.begin(), a.end());
  ll ans = a[0]+1;
  loop(i, n-1)
  {
    ans = (ans*(a[i]-a[i-1]+1))%mod;
  }
  cout<<ans<<"\n";
}

#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int n = 1; 
	for (int i = 0; i < N; i++) {
		n *= 2;
	}
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		v[i].first = A[i];
		v[i].second = i;
	}
	for (int i = 0; i < N - 1; i++) {
		vector<pair<int, int>> tmp;
		for (int i = 0; i < n; i += 2) {
			if (v[i].first > v[i + 1].first) {
				tmp.emplace_back(v[i].first, v[i].second);
			}
			else {
				tmp.emplace_back(v[i + 1].first, v[i + 1].second);
			}
		}
		v = tmp;
		n /= 2;
	}
	cout << (v[0].first < v[1].first ? v[0].second + 1 : v[1].second + 1) << endl;
	return 0;
}