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

int main(){

//2位を出力して、O(n)で2位の順番を探しだす
int n;
cin >> n;
int n_sub=1;
for(int i=0;i<n;i++){
    n_sub*=2;
}

vector<int> a(n_sub/2);
vector<int> a_sub(n_sub/2);
vector<int> b(n_sub/2);
vector<int> b_sub(n_sub/2);

for(int i=0;i<n_sub;i++){
    if(i<(n_sub/2)){
        cin >> a_sub[i];
        a[i] = a_sub[i];
    }else{
        cin >> b_sub[i-(n_sub/2)];
        b[i-(n_sub/2)] = b_sub[i-(n_sub/2)];
    }
}
sort(a_sub.begin(),a_sub.end());
sort(b_sub.begin(),b_sub.end());

int max_a = a_sub[(n_sub/2)-1];
int max_b = b_sub[(n_sub/2)-1];
int max_c = min(max_a,max_b);

for(int i=0;i<n_sub/2;i++){
    if(a[i]==max_c){
        cout << i+1 << endl;
        return 0;
    }
}

for(int i=0;i<n_sub/2;i++){
    if(b[i]==max_c){
        cout << (n_sub/2)+i+1 << endl;
        return 0;
    }
}

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

typedef long long ll;
typedef long double ld;

ll pow(ll a, ll b)
{
  for (int i = 1; i <= b; i++)
  {
    a *= a;
    if (i = b)
      return a;
  }
}

int main()
{
  ll n;
  cin >> n;
  ll max_1 = 0, max_2 = 0;
  ll p = 0, q = 0;
  ll k = pow(2, n - 1);
  vector<ll> a(k * 2);
  for (int i = 0; i < 2 * k; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < k; i++)
  {
    if(max_1<=a[i]){
    max_1 = max(max_1, a[i]);
      p=i;
    }
    
  }
  for (int i = k; i < k * 2; i++)
  {
     if(max_2<=a[i]){
    max_2 = max(max_2, a[i]);
      q=i;
    }
  }

  if (min(max_1, max_2) == max_1)
    cout << p + 1 << endl;
  else
    cout << q + 1 << endl;
}