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

struct fastio{fastio(){cin.tie(nullptr);ios_base::sync_with_stdio(false);std::cout<<std::fixed<<setprecision(10);}}oitsaf;
template<class T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){for(auto const& vi:v)os<<vi<<" ";return os;}

int main() {
  int n;
  cin >> n;
  n--;
  vector<int> a(1 << n), b(1 << n);
  cin >> a >> b;
  auto amax = max_element(begin(a), end(a));
  auto bmax = max_element(begin(b), end(b));
  int ans = -1;
  if (*amax > *bmax) {
    ans = bmax - begin(b) + 1 + (1 << n);
  } else {
    ans = amax - begin(a) + 1;
  }
  cout << (ans) << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(1<<n);
    for(int i = 0;i < 1<<n;i++)cin >> a[i];
    vector<vector<pair<ll,ll> > > p(n+1);
    for(int i = 0;i < 1<<n;i++)p[0].push_back(make_pair(a[i],i));
    ll d = 0;
    while(1){
        if(p[d].size() <= 2)break;
        for(int i = 0;i < p[d].size();i++){
            if(i % 2 == 1)continue;
            ll num = 0;
            ll win = 0;
            if(p[d][i].first >= p[d][i + 1].first){
                num = p[d][i].second,win = p[d][i].first;
            }
            else{
                num = p[d][i + 1].second,win = p[d][i + 1].first;
            }
            p[d + 1].push_back(make_pair(win,num));
            //i++;
            //cout << i << " " << win << " " << num  << endl;
        }
        d++;
    }
    if(p[d][0].first >= p[d][1].first)cout << p[d][1].second + 1 << endl;
    else cout  << p[d][0].second + 1 << endl;
}