#include<iostream>
#include<algorithm>
using namespace std;
int getlen(int n)
{
int len = 1;
for (int i = 1; i <= n; i++) len *= 2;
return len;
}
struct tree
{
int level,flag;
};
int main()
{
int n, len, len1,temp=1;
tree t[129];
cin >> n;
len = getlen(n + 1) - 1;
len1 = getlen(n);
for (int i = len - len1; i < len; i++)
{
cin >> t[i].level;
t[i].flag = temp;
temp++;
}
for(int i=len-1;i>0;i-=2)
{
if (t[i].level >= t[i - 1].level)
{
t[(i - 1) / 2].level = t[i].level;
t[(i - 1) / 2].flag = t[i].flag;
}
else
{
t[(i - 1) / 2].level = t[i-1].level;
t[(i - 1) / 2].flag = t[i-1].flag;
}
}
cout << t[1].flag << endl;
return 0;
}