/*
      JAI SHREE RAM
*/
#include<bits/stdc++.h>
using namespace std;
#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fo(i,n)         for(i=0;i<n;i++)
#define foi(i,k,n)      for(i=k;i<n;i++)
#define wt              long t; cin>>t; while(t--)
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vl              vector<long>
#define vll             vector<long long>
#define mii             map<int,int>
#define pqi             priority_queue<int> 
#define pr(a)           cout<<a<<" ";
#define pra(a)          for(i=0;i<a.size();i++){cout<<a[i]<<" ";} 
#define pry             cout<<"YES\n"
#define prn             cout<<"NO\n"
#define endl             cout<<endl;

bool p[1000000]={0};
vl v;
void primeFacTillN(ll n)
{  
  p[0]=1;
  p[1]=1;
  // int i=0;
  for(ll i=2;i<=n;i++)
  {
    if(!p[i])
    {
      for(ll j=2*i;j<=n;j+=i)
        p[j]=1;
    }
  }
  for(ll i=2;i<=n;i++)
  {
    if(!p[i])
      v.pb(i);
  }
 }


//base any number 

long long baseN(long long a,long long n){
if(a<n)
return a;
else{
return(a%n + 10*baseN((a/n),n));
}
}
ll binarySearch(ll arr[], ll l, ll r, ll x) 
{   ll count=0;
    while (l <= r) { 
        ll m = l + (r - l) / 2; 
        count++;
        // Check if x is present at mid 
        if (arr[m] == x) 
            return count; 
  
        // If x greater, ignore left half 
        if (arr[m] < x) 
            l = m + 1; 
  
        // If x is smaller, ignore right half 
        else
            r = m - 1; 
    } 
  
    // if we reach here, then element was 
    // not present 
    return -1; 
} 
ll binarySearch2(ll a[],ll l,ll h,ll k)
{
  ll count=0;
  while(l<=h)
  {
    ll mid= (l+h)>>1;
    count++;
    if(a[mid]>mid)
      l=mid+1;
    else if (a[k]<mid)
      h=mid-1;
    else return mid;
  }
  return -1;
  
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll isprime(ll x)
{
  ll i;
  for(i=2;i*i<=x;i++)
  {
    if(x%i==0)
      return 1;
  }
  return 0;
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("outputhelp2.txt", "w", stdout);
#endif
  
  ll n,i;
  cin>>n;
  n= pow(2,n);
  vll v(n);

  for(ll i=0;i<n;i++)
    cin>>v[i];
  vll w(n);
  for(i=0;i<n;i++)
    w[i]=v[i];
  while(v.size()>2){
  for(i=0;i<=v.size()-2;i+=2)
  {
    if(v[i]>v[i+1])
      {v.erase(v.begin()+i+1);
        i--;
      }
    else
      {v.erase(v.begin()+i);
        i--;
      }

  }}

  ll x = *min_element(v.begin(), v.end());


  for(i=0;i<n;i++)
  {
    if(x== w[i])
    {
      cout<<i+1;
      break;
    }
  }


return 0;
}

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

int main() {
  int n;
  cin >> n;
  int c = 1 << n;
  vector<int> a(c);
  for (int i = 0; i < c; i++) {
    cin >> a[i];
  }
  map<int, int> mp;
  for (int i = 0; i < c; i++) {
    mp[a[i]] = i + 1;
  }

  while (a.size() > 2) {
    vector<int> na;
    for (int i = 0; i < a.size(); i += 2) {
      na.push_back(max(a[i], a[i + 1]));
    }
    swap(a, na);
  }
  int ans = min(a[0], a[1]);
  cout << mp[ans] << endl;
  return 0;
}