#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int x=0,y=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*y;
}
int n,a[200010],b[200010],c[10][2000010],cnt[10];
int ans;
bool cmp(int x,int y)
{
	return x>y;
}
signed main()
{
	n=read();
	for(int i=0;i<n;i++)
	{
		a[i]=read(),ans+=a[i];
	}
	for(int j=0;j<n;j++)
	{
		b[j]=read();
		c[j%2][++cnt[j%2]]=b[j]-a[j];
	}
	int ji=ans;
	sort(c[1]+1,c[1]+1+cnt[1],cmp);
	sort(c[0]+1,c[0]+1+cnt[0],cmp);
	for(int i=1;i<=cnt[0];i++)
	{
//		cout<<c[0][i]<<' '<<c[1][i]<<endl;
		ji+=c[1][i]+c[0][i];
		ans=max(ans,ji);
	}
	cout<<ans<<endl;
}
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<pair<int, int>> A(1<<N);
    for (int i=0; i<(1<<N); ++i) {
        cin >> A[i].first;
        A[i].second = i+1;
    }

    vector<pair<int, int>> nA(1<<N);
    for (int i=0; i<N-1; ++i) {
        for (int j=0; j<(1<<(N-i-1)); ++j) nA[j] = max(A[2*j], A[2*j+1]);
        A.swap(nA);
    }
    cout << min(A[0], A[1]).second << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}
