#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

ll cal(ll arr[], ll n, vector<ll> v) {
	if(n == 0) {
		ll ans = 0;
		for(auto it : v ) {
			ans = ans ^ it;
		}
		return ans;
	}
	else {
		if(v.size() == 0) {
			v.pb(arr[n-1]);
			return cal(arr,n-1,v);
		}
		else {
			vector<ll> temp = v;
			temp.pb(arr[n-1]);
			v.back() = v.back() | arr[n-1];
			return min(cal(arr,n-1,v), cal(arr,n-1,temp));
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll arr[n];
		f(i,n) cin>>arr[i];
		vector<ll> v;
		cout<<cal(arr,n,v);
	}
 	return 0;
}

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

typedef long long int ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	vector < int > a((int)(1 << n) + 1), last, win;
	for (int i = 1; i <= (1 << n); i++) {
		cin >> a[i];
		last.push_back(i);
	}
	
	while(last.size() > 2) {
		for (int i = 0; i < (int)last.size(); i += 2) {
			if (a[last[i]] > a[last[i + 1]]) {
				win.push_back(last[i]);
			} else {
				win.push_back(last[i + 1]);
			}
		}
		last = win;
		win.clear();
	}
	
	if (a[last[0]] > a[last[1]]) {
		cout << last[1] << '\n';
	} else {
		cout << last[0] << '\n';
	}
}
