#include<bits/stdc++.h>
using namespace std; 

#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug cout<<"debug"<<endl;
ll Pow(ll x,ll y){return y==0?:x*pow(x,y-1);}
int main()
{
     ///"In the name of Allah,most gracious and most merciful"///
     
  
        ll i,j,x,y,z,count=0,sum=0,n,m;
        cin>>n;
        x=Pow(2,n);
        vector<ll>a(x);
        vector<pair<ll,ll> >v,v1,v2;
        for(ll i=0;i<x;i++)
        {
            cin>>a[i];
            v.pb(mp(a[i],i+1));
        }
        if(n==1){
           if(v[0].ff>v[1].ff)
            {
                cout<<v[1].ss<<endl;
            }
            else 
            {
                cout<<v[0].ss<<endl;
            }
        }
        else {
        while(1){
        if(sum==0){
        for(ll i=0;i<v.size();i+=2)
        {
            if(v[i].ff>v[i+1].ff)
            v1.pb(mp(v[i].ff,v[i].ss));
            else 
            v1.pb(mp(v[i+1].ff,v[i+1].ss));
        }
        sum=1;
        }
        else if(count==0)
        {
         for(ll i=0;i<v1.size();i+=2)
        {
            if(v1[i].ff>v1[i+1].ff)
            v2.pb(mp(v1[i].ff,v1[i].ss));
            else 
            v2.pb(mp(v1[i+1].ff,v1[i+1].ss));
        }
         count=1;
         v1.clear();
        }
        else if(count==1)
        {
         for(ll i=0;i<v2.size();i+=2)
        {
            if(v2[i].ff>v2[i+1].ff)
            v1.pb(mp(v2[i].ff,v2[i].ss));
            else 
            v1.pb(mp(v2[i+1].ff,v2[i+1].ss));
        }
         count=0;
         v2.clear();
        }
         if(v1.size()==2 || v2.size()==2)
         break;
        }
        if(v1.size()==2)
        {
            if(v1[0].ff>v1[1].ff)
            {
                cout<<v1[1].ss<<endl;
            }
            else 
            {
                cout<<v1[0].ss<<endl;
            }
        }
        else if(v2.size()==2)
        {
             if(v2[0].ff>v2[1].ff)
            {
                cout<<v2[1].ss<<endl;
            }
            else 
            {
                cout<<v2[0].ss<<endl;
            }
        }

        }


    return 0;
}


#include <bits/stdc++.h>


using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vb=vector<bool>;using vvb=vector<vb>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;

#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()

// cin and cout of a vector
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}

// for loop
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revv(i, a, b) for (int i = (int)(b-1); i >= (int)(a); i--)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
// #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
// #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
// #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
// #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)

// Yes/no
#define cho(n,a,b) cout<< ((n)?a:b)<<endl;
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}


#define pb push_back
#define rsortv(v) sort((v).rbegin(), (v).rend())
#define sortv(v) sort((v).begin(), (v).end())

// max/min
template<class T, class U>bool chmax(T&a,const U&b){bool x=a<b;x?a=b:b;return x;}template<class T, class U>bool chmin(T&a,const U&b){bool x=a>b;x?a=b:b;return x;}
template<class T, class U>auto max(const T&a,const U&b){return a<b?b:a;}template<class T, class U>auto min(const T&a,const U&b){return a<b?a:b;}

//========================================
//========================================
//========================================

template<class T>auto minv(const T&a){return *min_element(all(a));}
template<class T>auto smod(T a, T b){a %= b; if (a < 0); a+= b; return a;}
template<class T>auto maxv(const T&a){return *max_element(all(a));}
template<class T>auto sumv(const T&a){ll sum = 0; for(auto x: a) sum+= x; return sum;}

template<class T>void pr(const T&a){cout << a << endl;}
template<class T>void pr_precise(const T&a){cout.precision(10); cout << fixed << a << endl;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
// ll M = 1000000007;
ll M = 998244353;


int main() {
    int cases = 1;
    // cin >> cases;

    rep(CASE, cases){
        int p;
        cin >> p;
        int n = (1<< (p-1));
        vl A(n);
        vl B(n);
        
        cin >> A;
        cin >> B;

        ll a = maxv(A);
        ll b = maxv(B);
        if (a < b) pr(1 + std::distance(A.begin(), std::max_element(A.begin(), A.end())));
        else pr(1 + n+ std::distance(B.begin(), std::max_element(B.begin(), B.end())));
        // pr(min(a,b));
        

        // pr(A);
        // pr(B);
        // pr(C);

    }
    return 0;
}