#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define dumpn(x) cout << " " << #x << "=" << x << endl
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

void show(map<lint, lint> mp) {
    for(auto e: mp) {
        cout << e.first << "|" << e.second << endl;
    }
}

int main(void) {
    lint n; cin >> n;
    vector<lint> x(3*n); repeat(i, 3*n) cin >> x[i];
    
    vector<lint> former(n+1, 0), latter(n+1, 0);
    {
        vector<lint> y(2*n); repeat_from(i, n, 3*n) y[i-n] = -x[i];
        map<lint, lint> mp_cnt, mp_rmv;
        lint sum = 0;
        repeat(i, 2*n) {
            mp_cnt[ y[i] ] += 1;
            mp_rmv[ y[i] ] = 0;
            sum += y[i];
        }
        lint cnt = 0;
        lint pos = 0;
        for(auto it = mp_cnt.begin(); it != mp_cnt.end(); ++it) {
            lint t = it->second;
            if (cnt + t >= n) {
                mp_rmv[ it->first ] += (n - cnt);
                sum -= (it->first) * (n - cnt);
                pos = it->first;
                break;
            }
            cnt += t;
            mp_rmv[ it->first ] = t;
            sum -= (it->first) * t;
        }
        repeat(i, n+1) {
            //cout << "\n";
            //cout << "mp_cnt\n"; show(mp_cnt);
            //cout << "mp_rmv\n"; show(mp_rmv);
            //dumpn(sum);
            //dumpn(pos);
            latter[i] = sum;
            if (mp_rmv[ y[i] ] > 0) {
                mp_rmv[ y[i] ] -= 1;
                mp_cnt[ y[i] ] -= 1;
            }
            else {
                if (mp_rmv[ pos ] > 0) {
                    mp_rmv[ pos ] -= 1;
                    mp_cnt[ y[i] ] -= 1;
                    sum = sum - y[i] + pos;
                }
                else {
                    auto it = mp_rmv.find(pos);
                    while (mp_rmv[pos] == 0 && it != mp_rmv.begin()) {
                        --it;
                        pos = it->first;
                    }
                    mp_rmv[ pos ] -= 1;
                    mp_cnt[ y[i] ] -= 1;
                    sum = sum - y[i] + pos;
                }
            }
        }
    }
    
    {
        vector<lint> y(2*n); repeat_from(i, 0, 2*n) y[i] = x[2*n - 1 - i];
        map<lint, lint> mp_cnt, mp_rmv;
        lint sum = 0;
        repeat(i, 2*n) {
            mp_cnt[ y[i] ] += 1;
            mp_rmv[ y[i] ] = 0;
            sum += y[i];
        }
        lint cnt = 0;
        lint pos = 0;
        for(auto it = mp_cnt.begin(); it != mp_cnt.end(); ++it) {
            lint t = it->second;
            if (cnt + t >= n) {
                mp_rmv[ it->first ] += (n - cnt);
                sum -= (it->first) * (n - cnt);
                pos = it->first;
                break;
            }
            cnt += t;
            mp_rmv[ it->first ] = t;
            sum -= (it->first) * t;
        }
        repeat(i, n+1) {
            //cout << "\n";
            //cout << "mp_cnt\n"; show(mp_cnt);
            //cout << "mp_rmv\n"; show(mp_rmv);
            //dumpn(sum);
            //dumpn(pos);
            former[i] = sum;
            if (mp_rmv[ y[i] ] > 0) {
                mp_rmv[ y[i] ] -= 1;
                mp_cnt[ y[i] ] -= 1;
            }
            else {
                if (mp_rmv[ pos ] > 0) {
                    mp_rmv[ pos ] -= 1;
                    mp_cnt[ y[i] ] -= 1;
                    sum = sum - y[i] + pos;
                }
                else {
                    auto it = mp_rmv.find(pos);
                    while (mp_rmv[pos] == 0 && it != mp_rmv.begin()) {
                        --it;
                        pos = it->first;
                    }
                    mp_rmv[ pos ] -= 1;
                    mp_cnt[ y[i] ] -= 1;
                    sum = sum - y[i] + pos;
                }
            }
        }
    }
    
    lint ans = former[0] + latter[n];
    repeat_to(i, n) {
        ans = max(ans, former[i] + latter[n-i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 32640