#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 200005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
void ash(){
	boost 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout); 
#endif 
}   

int main()
{
    ash();
    ll n;
    cin>>n;
   
    ll p=1<<n;
    ll i;
     vector<pair<ll,ll>> m(p);
    REP(i,p)
    {
        ll x;
        cin>>x;
        m[i]={x,i+1};
    }
    vector<pair<ll,ll>> m1;
    while(p!=2)
    {
    for(i=0;i<p;i+=2)
    {
       // cout<<m[i].fp<<"a"<<m[i].sp<<" "<<m[i+1].fp<<"a"<<m[i+1].sp<<"\n";
     if(m[i].fp>m[i+1].fp)
    m1.pb({m[i].fp,m[i].sp});
    else
    m1.pb({m[i+1].fp,m[i+1].sp});
    }
    //cout<<"\n";
    m.clear();
    m=m1;
    m1.clear();
    p/=2;
}
if(m[0].fp<m[1].fp)
    cout<<m[0].sp;
else
    cout<<m[1].sp;
}
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>  using oset =
    tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;
#define odrkey order_of_key
#define fbodr find_by_order
#define ll long long
#define sq(a) ((a)*(a))
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pi 3.1415926536
#define nwl cout <<"\n";
#define MAXN 100009
#define ff first
#define ss second
#define pb push_back
#define pf push_front
ll Pow(ll a, ll b) {
	if (a == 0) return 0LL;
	ll ans = 1;
	for (int i = 0; i < b; i++) {
		ans *= a;
	}
	return ans;
}
ll lcm(ll a, ll b) {
	return (a * b) / __gcd(a, b);
}
ll md = (ll) 1e9 + 7;
ll bigmod(ll a, ll b, ll m) {
	if (b == 0) return 1LL;
	ll tm = bigmod(a, b / 2, m);
	tm = (tm * tm) % m;
	if (b % 2) tm = (tm * a) % m;
	return tm;
}
ll ncr(ll n, ll r) {
	if (r > n - r) r = n - r;
	ll up = 1;
	ll down = 1;
	for (ll i = 0; i < r; i++) {
		up = (up * (n - i)) % md; /* md== mod */
		down = (down * (r - i)) % md;
	}
	return (up * bigmod(down, md - 2, md)) % md;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n ;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		if (x > 10) {
			x -= 10;
			ans += x;
		}
	}
	cout << ans << endl;
}
