#include<iostream>
#include<map>
using namespace std;
int a[70000];
int main(){
	int n,ans;cin>>n;map<int,bool>mp;
	for(int i=0;i<(1<<n);++i)cin>>a[i];
	for(int i=0;i<n;++i){int x=0,y=1;
		for(int j=0;j<(1<<(n-i-1));++j){
			while(mp[x])++x;
			while(mp[y]||y<=x)++y;
			if(a[x]>a[y])mp[y]=1,ans=y,x=y+1,y=x+1;
			else mp[x]=1,ans=x,x=y+1,y=x+1;
		}
	} 
	cout<<ans+1<<endl;
	return 0;
}
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#define rg register
inline int read(){
	rg int x=0,fh=1;
	rg char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*fh;
}
const int maxn=1e6+5;
int n,a[maxn],mmax,mmax2,cs1,cs2,jl1,jl2;
int main(){
	n=read();
	mmax=(1<<n);
	mmax2=mmax/2;
	for(rg int i=1;i<=mmax;i++) a[i]=read();
	for(rg int i=1;i<=mmax2;i++){
		if(a[i]>cs1){
			cs1=a[i];
			jl1=i;
		}
	}
	for(rg int i=mmax2+1;i<=mmax;i++){
		if(a[i]>cs2){
			cs2=a[i];
			jl2=i;
		}
	}
	if(a[jl1]>a[jl2]) printf("%d\n",jl2);
	else printf("%d\n",jl1);
	return 0;
}
