#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < int(NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)

template <typename T>
void chmin(T& a, T b){ if(a > b) a = b; }
template <typename T>
void chmax(T& a, T b){ if(a < b) a = b; }


int main()
{
    cin.tie( 0 ); ios::sync_with_stdio( false );
    // ----------------------------------------------------------------
    
    ull n = 0;
    cin >> n;
    vector<ll> vec( 2*n, 0 );
    ll sum = 0;
    REP(i, 2*n) {cin >> vec[i]; sum+=vec[i];}
    
    ll aosum = 0;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    REP(i, n)
    {
        ll a = n - 1 - i;
        ll b = n + 0 + i;
        q.push(vec[a]); q.push(vec[b]);
        aosum += q.top();
        q.pop();
    }

    cout << sum - aosum << endl;
    
    // ----------------------------------------------------------------
    return 0;
}
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> V(2*N);
  int i;
  for(i=0;i<2*N;i++)cin >> V[i];
  priority_queue<int,vector<int>,greater<int>> q;
  for(i=0;i<N;i++) {
    q.push(V[N-i-1]);
    q.push(V[N+i]);
    q.pop();
  }
  long long ans = 0;
  while(!q.empty()) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}