#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main() {
	vector<long long> a;
	queue<long long> q;
	long long n, m = 1;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		m *= 2;
	n = m;
	for (int i = 0; i < n; ++i) {
		cin >> m;
		a.push_back(m);
		q.push(m);
	}long long b, c;
	while (q.size() != 2) {
		long long x = q.size();
		for (int i = 1; i <= x; i += 2) {
			b = q.front(); q.pop();
			c = q.front(); q.pop();
			q.push(max(c, b));
		}
	}
	b = q.front(); q.pop();
	c = q.front(); q.pop();
	b = min(b, c);
	for (int i = 0; i < n; ++i) {
		if (b == a[i]) {
			cout << i + 1;
			return 0;
		}
	}
	return 0;
}
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vec vector
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int m = 1<<n;
	vec<int> a(m);
	for (int& x : a) cin >> x;
	
	vec<vec<int>> b(2);
	for (int i=0; i<m; i++) b[0].push_back(i);
	for (int t=0; t<n-1; t++) {
		bool p = t&1;
		bool q = 1-p;
		sort(b[p].begin(), b[p].end());
		for (int i=0; i<b[p].size(); i+=2) {
			if (a[b[p][i]] < a[b[p][i+1]]) b[q].push_back(b[p][i+1]);
			else b[q].push_back(b[p][i]);
		}
		b[p].clear();
	}
	
	bool p = (n-1)&1;
	if (a[b[p][0]] < a[b[p][1]]) cout << b[p][0]+1;
	else cout << b[p][1]+1;
	cout << '\n';
}