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

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORd(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); ++it)
#define ms(x, n) memset(x, n, sizeof(x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define prec(x) fixed << setprecision((x))
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define long long long
#define db(x) cerr << #x << " = " << (x) << ", ";
#define endln cerr << "\n";
#define chkpt cerr << "------\n";
template<class T> inline int chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline int chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
typedef pair<int, int> pi;
const int INF = (int) 1e9;
const long LINF = (long) 1e18;

const int maxn = 3 * 100000 + 15;

int n, a[maxn], bit[maxn], m[maxn], bit1[maxn];
long f[maxn], g[maxn];
vector<int> zip;

void upd(int x, int v) {
    for (int i = x; i < maxn; i += i & -i)
        bit[i] += v;
}

int query(int x) {
    int ret = 0;
    for (int i = x; i > 0; i -= i & -i)
        ret += bit[i];
    return ret;
}

void upd1(int x, int v) {
    for (int i = x; i > 0; i -= i & -i)
        bit1[i] += v;
}

int query1(int x) {
    int ret = 0;
    for (int i = x; i < maxn; i += i & -i)
        ret += bit1[i];
    return ret;
}

void initMax() {
    long sum = 0;
    FOR(i, 1, n) {
        int x = lower_bound(all(zip), a[i]) - zip.begin() + 1;
        upd(x, 1);
        sum += a[i];
    }
    f[n] = sum;
    FOR(i, n + 1, 3 * n) {
        int x = lower_bound(all(zip), a[i]) - zip.begin() + 1;
        int l = 1, r = x, p = 0;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (query(mid)) {
                p = mid;
                r = mid - 1;
            } else
                l = mid + 1;
        }
        if (p) {
            upd(p, -1);
            sum -= m[p];
            upd(x, 1);
            sum += a[i];
        }
        f[i] = sum;
    }
}

void initMin() {
    long sum = 0;
    FORd(i, 3 * n, 2 * n + 1) {
        int x = lower_bound(all(zip), a[i]) - zip.begin() + 1;
        upd1(x, 1);
        sum += a[i];
    }
    g[2 * n + 1] = sum;
    FORd(i, 2 * n, 1) {
        int x = lower_bound(all(zip), a[i]) - zip.begin() + 1;
        int l = x, r = 3 * n, p = 0;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (query1(mid)) {
                p = mid;
                l = mid + 1;
            } else
                r = mid - 1;
        }
        if (p) {
            upd1(p, -1);
            sum -= m[p];
            upd1(x, 1);
            sum += a[i];
        }
        g[i] = sum;
    }
}

int main() {
//    freopen("ARC074B.INP", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    FOR(i, 1, 3 * n) {
        cin >> a[i];
        zip.pb(a[i]);
    }
    sort(all(zip));
    uni(zip);
    FOR(i, 1, 3 * n) {
        int x = lower_bound(all(zip), a[i]) - zip.begin() + 1;
        m[x] = a[i];
    }
    initMax();
    initMin();
    long ans = -LINF;
    FOR(i, n, 2 * n) {
        chkmax(ans, f[i] - g[i + 1]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 10480