#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define all(x) x.begin(),x.end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<pair<ll,ll>> arr(n);
    REP(i,n){
        cin>>arr[i].ff>>arr[i].ss;
    }
    ll ans=1e18;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(i==j){
                ans=min(ans,arr[i].ff+arr[i].ss);
            }
            else{
                ans=min(ans,max(arr[i].ff,arr[j].ss));
            }
        }
    }
    cout<<ans<<endl;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{   if(k>n)
        return 0;
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
lld n;
vector<lld>ar;
lld fun(lld a, lld b)
{
    if(a+1==b)
        return max(ar[a],ar[b]);
    lld mid=(a+b)/2;
    if(a==0 && b==n-1)
        return min(fun(a,mid),fun(mid+1,b));
    else
        return max(fun(a,mid),fun(mid+1,b));

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        n=(1<<n);
        map<lld,lld>m;
        for(i=0;i<n;i++)
        {
            lld a;
            cin>>a;
            ar.push_back(a);
            m[a]=i+1;
        }
        if(n==2)
        {
            cout<<m[min(ar[0],ar[1])]<<endl;
            return 0;
        }
        cout<<m[fun(0,n-1)]<<endl;
    }
}


