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

int main() {
  ll N; cin>>N;
  vector<ll> A(pow(2,N));
  for(int i=0; i<pow(2,N); ++i) cin>>A[i];
  // 選手を半分に分ける
  // 0-2^(N-1) 2^(N-1)-2-N-1
  pair<ll,ll> playerA(0,0), playerB(0,0);
  for(int i=0; i<pow(2,N-1); ++i) {
    if(A[i]>playerA.first) playerA={A[i],i+1};
  }
  for(int i=pow(2,N-1); i<pow(2,N); ++i) {
    if(A[i]>playerB.first) playerB={A[i],i+1};
  }

  if(playerA.first>playerB.first) cout<<playerB.second<<endl;
  else cout<<playerA.second<<endl;
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int &it : a) cin >> it;
    for (int &it : b) cin >> it;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i] * b[i];
    }
    cout << (sum == 0 ? "Yes\n" : "No\n");
    return 0;
}