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

#define rapid() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'

int main(){

	rapid();

	int n;
  	cin>>n;
  	int n2=1<<n;
  	vector<int>a(n2);
  	map<int,int>mp;
  	for(int i=0;i<n2;i++){
  		cin>>a[i];
  	}
  	for(int i=0;i<n2;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;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define ll long long
#define boost ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define endl "\n"

////@Deepak404-------------------------------------------------------------------->

const ll mxN = 1e5;
const ll mod = 1e9 + 7;

void solve()
{
    ll n;
    cin >> n;
    deque<int> dq;
    int in;
    n = pow((ll)2, n);
    vector<int> a(n / 2);
    vector<int> b(n / 2);
    for (auto &&i : a)
    {
        cin >> i;
    }
    for (auto &&i : b)
    {
        cin >> i;
    }
    auto mxa = max_element(all(a));
    auto mxb = max_element(all(b));
    int ans;
    if (*mxa < *mxb)
        ans = (mxa - a.begin()) + 1;
    else
        ans = (mxb - b.begin()) + (n / 2) + 1;
    cout << ans << "\n";
}

int main()
{
    boost;
    int tc = 1;
    // cal();
    // sieve();
    // cin >> tc;
    for (int i = 1; i <= tc; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }

#ifndef ONLINE_JUDGE
    cerr << "Time: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << " ms\n";
#endif
    return 0;
}
