#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1LL << 62;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll V[400010];
ll sum;
int main() {
    cin >> N;
    for (int i = 0; i < 2 * N; i++) {
        cin >> V[i];
        sum += V[i];
    }
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        pq.push(V[i]);
        pq.push(V[2 * N - i - 1]);
        ans += pq.top();
        pq.pop();
    }
    cout << sum - ans << endl;
}
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

long long sisu(long long n, long long k) {
	long long a = 1;
	for (long long i = 0; i < k; i++) {
		a *= n;
	}
	return a;
}

int main() {

	int N;
	cin >> N;

	long long max1=-1, max2=-1, b1,b2;

	vector<long long> A(sisu(2, N-1));
	vector<long long> B(sisu(2, N-1));
	vector<pair<long long, long long>> S;
	for (int i = 0; i < sisu(2, N); i++) {
		long long k;
		cin >> k;
		if (i >= sisu(2, N - 1)) {
			B.at(i - sisu(2, N - 1)) = k;
			if (max2 < k) {
				max2 = k;
				b2 = i + 1;
			}
		}
		else {
			A.at(i) = k;
			if (max1 < k) {
				max1 = k;
				b1 = i + 1;
			}
		}
		S.push_back(make_pair(k, i));
	}
	sort(S.begin(), S.end());

	if (S.at(sisu(2, N) - 1).second >= sisu(2, N - 1)){
		cout << b1;
	}
	else {
		cout << b2;
	}
}

