#include <stdio.h>
#include <utility>
#include <vector>
#include <numeric>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::vector<int> a(1 << n);
	for (auto &i : a) i = ri();
	
	std::vector<int> remaining(1 << n);
	std::iota(remaining.begin(), remaining.end(), 0);
	
	for (int i = 1; i <= n; i++) {
		std::vector<int> next_remaining;
		for (int j = 0; j < 1 << (n - i); j++) {
			if (a[remaining[j * 2]] > a[remaining[j * 2 + 1]]) next_remaining.push_back(remaining[j * 2]);
			else next_remaining.push_back(remaining[j * 2 + 1]);
		}
		if (i == n) {
			printf("%d\n", 1 + (remaining[0] == next_remaining[0] ? remaining[1] : remaining[0]));
			return 0;
		}
		remaining = next_remaining;
	}
	
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int64_t num = 1 << N;
    vector<int> A(num), B(num);
    for(int i=0; i<num; i++){
        cin >> A[i];
        B[i] = i;
    }
    for(int i=1; i<N; i++){
        int split = 1 << (i-1);
        for(int j=(1<<i); j<=num; j+=(1<<i)){
            if(A[j-1] < A[j-split-1]){
                A[j-1] = A[j-split-1];
                B[j-1] = B[j-split-1];
            }
        }
    }

    if(A[num/2-1] > A[num-1]){
        cout << B[num-1]+1 << endl;
    } else {
        cout << B[num/2-1]+1 << endl;
    }
    return 0;
}