#include <iostream>
#include <cstdio>
#include <vector>
#define N 1000005
using namespace std;

int n, s, ans, a[N], b[N], v[N];
vector<int> num;
int f(int p) {return p > 0 ? p : -p;}
int main()
{
    int i, j, k;
    cin >> n;
    for (i = 0, j = 1; i < n; i++, j *= 2);
    for (i = 1; i <= j; i++) {
        scanf ("%d", &a[i]);
    }
    for (i = 1; i <= n; i++) {
        num.clear();
        for (k = 1; k <= j; k++) {
            if (v[k]) continue;
            num.push_back(k);
            if (num.size() == 2) {
                if (a[num[0]] > a[num[1]]) {v[num[1]] = 1; ans = num[1];}
                else {v[num[0]] = 1; ans = num[0];}
                num.clear();
            }
        }
    }
    cout << ans;
    return 0;
}

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

int main()
{
    int n;
    cin>> n;
    int iter = pow(2,n) + .000001;
    //cout<< iter;
    vector<int>vec;
    for(int i = 1; i <= iter; i++)
    {
        int input;
        cin>> input;
        vec.push_back(input);
    }
    if(n == 1)
    {
        if(vec[0] > vec[1])
            cout<< 2;
        else
            cout<< 1;

    }
    else
    {

    vector<int>temp;
    temp = vec;
    int res;
    while(1)
    {
        //vector<int>temp;
        //temp = vec;
        vector<int>vec_tmp;
        for(int i = 0; i < temp.size(); i+=2)
        {
            vec_tmp.push_back(max(temp[i],temp[i+1]));
        }
        temp = vec_tmp;
        if(vec_tmp.size() == 2)
        {
            res = min(vec_tmp[0],vec_tmp[1]);
            //cout<< vec_tmp[0] << " " << vec_tmp[1] << "\n";
            break;
        }
    }

    for(int i = 0; i < vec.size(); i++)
    {
        if(vec[i] == res)
        {
            cout<< i+1;
            break;
        }
    }

    }

    return 0;
}
