#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  int n, num = 0, t_n;
  cin >> n;
  num = pow(2,n);
  t_n = num;
  vt<int> a(num);
  vt<int> tp(num);
  rep(i,num){
    cin >> a[i];
    tp[i] = a[i];
  }

  while(num != 2) {
    rep(i,num){
      if (a[i] > a[i+1]) {
        a.erase(a.begin() + i+1);
      } else {
        a.erase(a.begin() + i);
      }
      num--;
    }
  }

  int p = a[0] > a[1] ? a[1] : a[0];

  rep(i,t_n){
    if(p == tp[i]){
      cout << i+1 << endl;
      break;
    }
  }

  return 0;
}

#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    long nNum = 1;
    for(int i = 0; i < n; i++){
        nNum *= 2;
    }
    vector<int> viNum(nNum);
    
    for(int i = 0; i < nNum; i++){
        scanf("%d", &viNum[i]);
    }
    vector<int> viNumTmp = viNum;
    long nNumTmp = nNum;
    while(nNumTmp > 2){
        nNumTmp /= 2;
        for(int i = 0; i < nNum; i++){
            viNumTmp[i] = max(viNumTmp[2*i], viNumTmp[2*i+1]);
        }
    }
    
    int nAns = min(viNumTmp[0], viNumTmp[1]);
    for(int i = 0; i < nNum; i++){
        if(viNum[i] == nAns){
            printf("%d", i+1);
        }
    }
    return 0;
}
