#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;cin>>N;
  vector<int>A(2*N);
  for(int i=0;i<2*N;i++)cin>>A[i];
  int ans=0;
  for(int i=0;i<2*N;i++)ans+=A[i];
  multiset<int>st;
  for(int i=0;i<N;i++){
    st.insert(max(A[N-1-i],A[N+i]));
    if(st.size()&&*st.begin()<min(A[N-1-i],A[N+i])){
      ans-=*st.begin();
      st.erase(st.begin());
      st.insert(min(A[N-1-i],A[N+i]));
    }else ans-=min(A[N-1-i],A[N+i]);
  }
  cout<<ans<<endl;
}
//My_Template

#include<bits/stdc++.h>

#define pb(a) push_back(a)
#define vec vector<long long int>
#define myfor(n) for(int i = 0; i < n; i++)
#define tc(t) int t; cin>>t; while(t--)
#define sortt(a) sort(a.begin(), a.end())
#define ll long long int
#define revit(a) reverse(a.begin(), a.end())
#define summ(a) accumulate(a.begin(), a.end(), 0ll)
#define M 1000000007ll
#define new_for(a) for(auto i : a)
#define INFI 9223372036854775807ll

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //code_goes_here-->

    int n;
    cin>>n;

    if(n > 1){

    vector<int> a(pow(2,n)), b, c;
    myfor(pow(2,n))
      cin>>a[i];
    c = a;

    for(int i = 0; i < pow(2,n) - 1; i+=2)
      b.pb(max(a[i], a[i+1]));

    a = b;

    while(b.size() != 2){
      b.clear();
      for(unsigned i = 0; i < a.size() - 1; i+=2)
        b.pb(max(a[i], a[i+1]));
      a = b;
    }

    int p = (b[0]>b[1]?b[1]:b[0]);

    for(int i = 0; i < pow(2, n); i++)
      if(c[i] == p){
        cout<<i+1<<endl;
        break;
      }
    }
    else{
      int a, b;
      cin>>a>>b;
      if(a > b)
        cout<<2<<endl;
      else
        cout<<1<<endl;
    }

    return 0;
}
