#include <bits/stdc++.h>

using namespace std;
#define int long long
const int MOD = 1000000007;
template <class T>
struct fenwick_tree {
	vector<T> x;
	fenwick_tree(int n) : x(n, 0) {}
	T sum(int i, int j) {
		if (i == 0) {
			T S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
			return S;
		} else
			return sum(0, j) - sum(0, i - 1);
	}
	void add(int k, T a) {
		for (; k < x.size(); k |= k + 1) x[k] += a;
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(2 * N);
	int res = 0;
	for (int i = 0; i < 2 * N; i++) {
		cin >> A[i];
	}
	vector<int> B;
	for (int i = 0; i < N; i++) {
		B.push_back(min(A[N - 1 - i], A[i + N]));
		B.push_back(max(A[N - 1 - i], A[i + N]));
	}

	int sum = 0;
	priority_queue<int> pq;
	for (int i = 1; i < 2 * N; i++) {
		if (i % 2 == 0) {
			int a = -pq.top();
			if (a < B[i]) {
				res += B[i] - a;
				pq.pop();
				pq.push(-B[i]);
			}
		} else {
			res += B[i];
			pq.push(-B[i]);
		}
	}
	// fenwick_tree<int> ft(2 * N);
	// for (int i = 0; i < 3 * N; i++) {
	// 	ft.add(i, 1);
	// }
	// vector<pair<int, int> > vp;
	// for (int i = 0; i < 2 * N; i++) {
	// 	vp.emplace_back(B[i], i);
	// }
	// sort(B.rbegin(), B.rend());
	// for (int i = 0; i < 2 * N; i++) {
	// 	//cerr << vp[i].first << " " << vp[i].second << endl;
	// 	int p = vp[i].second;
	// 	if (ft.sum(0, p) - 2 >= 0) {
	// 		ft.add(p, -2);
	// 		res += vp[i].first;
	// 	}
	// }
	cout << res << endl;
}
#include<iostream>
#include<algorithm>
#include<numeric>
#include<queue>
#include<vector>
using namespace std;
const int BUF = 400005;


int nVal;
int val[BUF];

void read() {
    cin >> nVal;
    nVal *= 2;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}

void work() {
    long long sum = accumulate(val, val + nVal, 0LL);
    priority_queue<int, vector<int>, greater<int> > Q;
    for (int i = 0, L = nVal / 2 - 1, R = nVal / 2; i < nVal; i += 2, --L, ++R) {
        Q.push(val[L]);
        Q.push(val[R]);
        sum -= Q.top();
        Q.pop();
    }
    
    cout << sum << endl;
}


int main() {
    read();
    work();
    return 0;
}
