// #include <bits/stdc++.h>
// #include <atcoder/all>

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>
#include <limits>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <locale>

using namespace std;
// using namespace atcoder;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ll long long
#define P pair<int, int>

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);

int main()
{
	int n;
	cin >> n;

	int total = pow(2, n);
	vector<ll> a(total);
	vector<ll> save;

	for (int i = 0; i < total; i++)
	{
		cin >> a[i];
	}

	copy(a.begin(), a.end(), back_inserter(save));

	int result = 0;

	while (true)
	{
		vector<int> removeIndexs;
		for (int i = 0; i < a.size() - 1; i+=2)
		{
			if (a[i] - a[i+1] > 0)
			{
				removeIndexs.push_back(i+1);
			}
			else
			{
				removeIndexs.push_back(i);
			}
		}

		if (a.size() == 2)
		{
			result = a[removeIndexs.back()];
			break;
		}

		for (int i = removeIndexs.size() - 1; i != static_cast<decltype(i)>(-1); i--)
		{
			a.erase(a.begin() + removeIndexs[i]);
		}
	}

	for (int i = 0; i < save.size() ; i++)
	{
		if (save[i] == result)
		{
			cout << i+1 << endl;
			break;
		}
	}

	return 0;
}
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(1 << (n+1));
    int p = (1 << n);
    vector<int> a(p);
    map<int, int> aa;
    for (int i = 0; i < p; ++i) {
        scanf("%d", &v[i+p]);
        aa[v[i+p]] = i;
    }
    for (int i = p-1; i > 0; --i) {
        v[i] = max(v[i*2],v[i*2+1]);
    }
    cout << aa[min(v[2], v[3])]+1 << "\n";
    return 0;
}