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

ll maxx(ll a, ll b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
ll minn(ll a, ll b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}

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

    ll N = pow(2, n);
    vector<pair<ll,ll>>v(N);
    ll i;

    for(i=0; i<N; i++){
        ll x;
        cin>>x;

        v[i].first = x;
        v[i].second = i+1;

        // cout<<v[i].first<<" "<<v[i].second<<endl;
    }


    ll cnt =0;
    ll res;

    while(1){

        if(v.size() == 2){
            if(v[0].first > v[1].first){
                res = v[1].second;
            }
            else{
                res = v[0].second;
            }
            break;
        }

        vector<pair<ll,ll>>vec;
        for(i=1; i<v.size(); i=i+2){
           
            if(v[i].first > v[i-1].first){
                vec.push_back(v[i]);
            }
            else{
                vec.push_back(v[i-1]);
            }
        }

        // for(i=0; i<vec.size(); i++){
        //     cout<<vec[i].first<<" "<<vec[i].second<<endl;
        // }
        // cout<<endl;

        v.clear();
        v = vec;

    }

    cout<<res;


    return 0; 
} 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(numeros) (ll) __builtin_popcountll(numeros)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " es " << (x) <<"\n"
#define test ll deftestcases;cin>>deftestcases;while(deftestcases--)
#define PI acos(-1)
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll>  vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
const ll inf = 2e18;
const ll mod = 1e9+7;   
const ll MAX = 6e2+15;



int main(){
    fastio;
    map<string,ll> mp;ll n;
    cin>>n;
    f(i,0,n){
        ll x;string s;
        cin>>s>>x;
        mp[s]=x;
    }
    ll maxi = 0;
    for(auto it : mp){
        if(maxi<it.sc){
            maxi = it.sc;
        }
    }
    string ans;ll aux  =0;
    for(auto it : mp){
        if(it.sc == maxi) continue;
        if(aux<it.sc){
            aux = it.sc;
            ans = it.fs;
        }
    }
    cout<<ans<<"\n";
    return 0; 
}