#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int A[1 << 16];

int main() {
  int n;
  S(n);
  int idx = 0;
  rep(i,0,1<<n) {
    S(A[i]);
    if(A[i] > A[idx]) {
      idx = i;
    }
  }
  int ans = -1;
  int y = (1 << (n - 1));
  rep(i,0,1<<n) {
    if((idx < y && i >= y) || (idx >= y && i < y)) {
      if(ans == -1 || A[i] > A[ans]) {
        ans = i;
      }
    }
  }
  P(ans + 1);
  return 0;
}

#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#define print(a) for(auto i : a) { cout << i << " "; } cout << endl;
#endif
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(int i = begin; i < (int)(end); i++)
#define contains(v, x) (find(all(v), x) != v.end())
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> T roundup(T a, T b){ return (a + b - 1) / b; }
const double PI = 3.14159265359;
const vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const vector<int> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
using ll = long long;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e9;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint;*/

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //mint::set_mod(MOD);
    
    int n;
    cin >> n;
    int p1 = -1, p2 = -1;
    int ans1 = -1, ans2 = -1;
    rep(i, 0, pow(2, n - 1)){
        int a;
        cin >> a;
        if(chmax(ans1, a)) p1 = i;
    }
    rep(i, 0, pow(2, n - 1)){
        int a;
        cin >> a;
        if(chmax(ans2, a)) p2 = pow(2, n - 1) + i;
    }
    cout << (ans1 < ans2 ? p1 : p2) + 1 << endl;
}
