#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(pow(2, n));
    for (int i = 0; i < pow(2, n); i++) {
        cin >> a.at(i);
    }
    vector<int> b;
    b = a;
    vector<int> copy;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < a.size() / 2; j++) {
            if (a.at(j * 2) > a.at(j * 2 + 1)) {
                copy.push_back(a.at(j * 2));
            }
            if (a.at(j * 2) < a.at(j * 2 + 1)) {
                copy.push_back(a.at(j * 2 + 1));
            }
        }
        a = copy;
        copy = {};
    }
    int ans = min(a.at(0), a.at(1));
    for (int i = 0; i < pow(2, n); i++) {
        if (ans == b.at(i)) {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
#define rep(i,n) for ( int i=0; i< (n); ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;


int winner(int i0, int k, int n, vector<int> &a){
    if(k==0) return i0;
    int w1 = winner(i0, k-1, n, a);
    int w2 = winner(i0+pow(2,k-1), k-1, n, a);
    //int w = a[w1]>a[w2]? w1 : w2;
    //cout << a[w1] << " " << a[w2] <<  " " << w << endl;
    if(k==n) return a[w1]>a[w2]? w2 : w1;
    return a[w1]>a[w2]? w1 : w2;
}

int main(){
    int n;
    cin >> n;
    int size = pow(2,n);
    vector<int> a(size);
    rep(i,size) cin >> a[i];
    cout << winner( 0, n, n, a)+1 << endl;
    return 0;
}