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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//最短経路（負閉路検出）Eが小さい時
void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { //O(|E||V|)
    d.resize(G.size());
    negative.resize(G.size());
    REP(i, d.size())
    d[i] = INF;
    REP(i, d.size())
    negative[i] = false;
    d[s] = 0;
    REP(k, G.size() - 1) {
        REP(i, G.size()) {
            REP(j, G[i].size()) {
                if(d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
                    d[G[i][j].to] = d[i] + G[i][j].cap;
                }
            }
        }
    }
    REP(k, G.size() - 1) {
        REP(i, G.size()) {
            REP(j, G[i].size()) {
                if(d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
                    d[G[i][j].to] = d[i] + G[i][j].cap;
                    negative[G[i][j].to] = true;
                }
                if(negative[i] == true)
                    negative[G[i][j].to] = true;
            }
        }
    }
}

void solve() {
    ll n;
    cin >> n;
    Array a(3 * n);
    REP(i, 3 * n) {
        cin >> a[i];
    }

    Array ma(n + 1, -INF);
    priority_queue<ll, vec<ll>, greater<ll>> que;

    ll sum = 0;
    REP(i, n) {
        que.push(a[i]);
        sum += a[i];
    }
    ma[0] = sum;

    REP(i, n) {
        que.push(a[i + n]);
        sum += a[i + n];
        sum -= que.top();
        que.pop();
        ma[i + 1] = sum;
    }

    Array mi(n + 1);
    priority_queue<ll> que2;
    sum = 0;
    REP(i, n) {
        que2.push(a[2 * n + i]);
        sum += a[2 * n + i];
    }
    mi[n] = sum;
    REP2(i, n) {
        que2.push(a[i + n]);
        sum += a[i + n];
        sum -= que2.top();
        que2.pop();
        mi[i] = sum;
    }

    ll ans = -INF;
    REP(i, n + 1) {
        chmax(ans, ma[i] - mi[i]);
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 9520