#include<bits/stdc++.h>
const int maxn=65536+5;
using namespace std;

int p[maxn];
int al(int n){
	int ans=1;
	while(n--){
		ans=ans*2;
	}
	return ans;
}

int main(){
	int n;
	cin>>n;
	int nn=al(n);
	int a,aa=0,b,bb=0;
	for(int i=1;i<=nn/2;i++){
		cin>>p[i];
		if(p[i]>aa){
			a=i;
			aa=p[i];	
		} 
	}
	for(int i=nn/2+1;i<=nn;i++){
		cin>>p[i];
		if(p[i]>bb){
			b=i;	
			bb=p[i];
		} 
	}
	if(p[a]>p[b]) cout<<b;
	else cout<<a;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;


int FindIndex(vector<int> v, int val)
{
    int index = 0;
    int i = 0;
    bool found = false;

    while(!found && i < v.size())
    {
        if (v[i] == val)
        {
            index = i;
            found = true;
        }
        i++;
    }

    return index + 1;
}

int main ()
{
    int n; cin >> n;
    vector<int> p;
    vector<int> indexes;
    vector<int> storage;
    for (int i = 0; i < pow(2, n); i++)
    {
        int x; cin >> x;
        p.push_back(x);
        storage.push_back(x);
    }

    while(p.size() != 2)
    {
        for (int i = 0; i < p.size(); i += 2)
        {
            if (p[i] < p[i + 1])
            {
                indexes.push_back(p[i + 1]);
            }
            else
            {
                indexes.push_back(p[i]);
            }
        }
        p = indexes;
        indexes.clear();
    }

    if (p[0] > p[1])
        cout << FindIndex(storage, p[1]);
    else
        cout << FindIndex(storage, p[0]);
}