#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 4e5 + 5;
int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < 2 * n; ++i) {
    scanf("%d", &a[i]);
  }
  return true;
}

priority_queue<int> pq;

void solve() {
  while (!pq.empty()) {
    pq.pop();
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    pq.push(a[i]);
    pq.push(a[2 * n - 1 - i]);
    res += pq.top();
    pq.pop();
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

#include<bits/stdc++.h>
#define int long long
#define N 400015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
int n,a[N],ans;
multiset<int> S;
signed main(){
	// freopen("53B.in","r",stdin);
	// freopen("mine.out","w",stdout);
	scanf("%lld",&n);
	rep(i,1,2*n) scanf("%lld",&a[i]);
	rep(i,1,n){
		S.insert(-a[i]); S.insert(-a[2*n-i+1]);
		// printf("%d\n",*S.begin());
		ans += *S.begin(); S.erase(S.begin());
	}
	printf("%lld\n", -ans);
	return 0;
}
/*
4
1 2 3 4 4 3 2 1
*/