#include<bits/stdc++.h>
#define sort(a) sort(a.begin(),a.end())
#define vpi vector< pair<long long,long long> >
#define pb push_back
#define ll long long
#define fast1 ios_base::sync_with_stdio(false)
#define fast2 cin.tie(NULL)
using namespace std;

int main() {
    fast1; fast2;
    ll n; cin>>n;

    ll sz = (1<<n);

    vector< pair<ll,ll> > a;

    for(ll i=0; i<sz; i++) {
        ll x; cin>>x;
        a.pb({x,i});
    }

    for(ll i=0; i<sz; i++) {
        vector<pair<ll,ll>> temp;
        if(a.size() == 2) {
            if(a[0].first > a[1].first) {
                cout<<a[1].second+1;
            } else {
                cout<<a[0].second+1;
            }
            break;
        }
        for(ll j=0; j<a.size(); j+=2) {
            if(a[j].first > a[j+1].first) {
                temp.pb(a[j]);
            } else {
                temp.pb(a[j+1]);
            }
        }
        a = temp;
    }
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ve vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod (ll)998244353
#define INF (ll)1e13+7
#define ld long double 
#define pll pair<ll,ll>
#define fi first
#define se second
#define mll map<ll,ll>
#define m_ve map<ll,ve>
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))
#define W(x) while(x--)
#define ld long double
#define all(x) x.begin(),x.end()
#define popcount(x) __builtin_popcountll(x)
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
//int dx[]={0,1,-1,0,0,1,-1,-1,1},dy[]={0,0,0,1,-1,1,-1,1,-1};	
const int N=300005;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); 
cout.tie(NULL);
int t;//cin>>t;
t=1;
while(t--)
{
	ll n;cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ll x;cin>>x;
		if(x>=10)
		ans+=x-10;
	}
	cout<<ans;
} 
 
 
 
}