// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5 + 5;



int n;

int a[maxN * 3];

int64_t f[maxN * 3], g[maxN * 3];

map<pair<int, int>, int> pos;



int cnt[maxN * 3];

int64_t fwt[maxN * 3];



void upd(int idx, int64_t val) {

    for(; idx < 3 * maxN; idx += idx & -idx) {

        fwt[idx] += val;

        cnt[idx] += 1;

    }

}



pair<int64_t, int> sum(int idx) {

    int64_t total = 0;

    int bar = 0;

    for(; idx > 0; idx -= idx & -idx) {

        total += fwt[idx];

        bar += cnt[idx];

    }

    return {total, bar};

}



pair<int64_t, int> sum(int l, int r) {

    auto rr = sum(r);

    auto ll = sum(l - 1);



    return {rr.first - ll.first, rr.second - ll.second};

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    cin >> n;



    int counter = 0;



    vector<pair<int, int> > vv;



    for(int i = 1; i <= 3 * n; i++) {

        cin >> a[i];

        vv.emplace_back(a[i], i);

    }



    sort(vv.begin(), vv.end());



    for(auto p : vv)

        pos[p] = ++counter;



    int64_t pre = 0;



    for(int i = 1; i <= 2 * n; i++) {

        upd(pos[{a[i], i}], a[i]);

        pre += a[i];

        int64_t curSum = pre;



        if(i >= n) {

            int k = i - n;



            if(k) {

                int lo = 1, hi = 3 * maxN - 1;

                while(lo <= hi) {

                    int mid = (lo + hi) / 2;

                    auto curPair = sum(1, mid);

                    if(curPair.second > k) {

                        hi = mid - 1;

                    } else if(curPair.second < k) {

                        lo = mid + 1;

                    } else {

                        curSum -= curPair.first;

                        break;

                    }

                }

            }



            f[i] = curSum;

        }

    }



    for(int i = 0; i < 3 * maxN; i++)

        fwt[i] = cnt[i] = 0;



    int64_t suf = 0;

    for(int i = 3 * n; i > n; i--) {

        upd(pos[{a[i], i}], a[i]);

        suf += a[i];

        int64_t curSum = suf;



        if(i <= 3 * n - n + 1) {

            int k = 3 * n - n + 1 - i;

            if(k) {

                int lo = 1, hi = 3 * maxN - 1;

                while(lo <= hi) {

                    int mid = (lo + hi) / 2;

                    auto curPair = sum(mid, 3 * maxN - 1);

                    if(curPair.second > k) {

                        lo = mid + 1;

                    } else if(curPair.second < k) {

                        hi = mid - 1;

                    } else {

                        curSum -= curPair.first;

                        break;

                    }

                }

            }



            g[i] = curSum;

        }

    }



    int64_t ans = -1e18;

    for(int i = n; i <= n + n; i++) {

        ans = max(ans, f[i] - g[i + 1]);

    }



    cout << ans << '\n';



    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



#define int long long

#define fi first

#define se second

#define sz(x) (int)(x).size()

#define all(x) (x).begin(), (x).end()

#define yn(x) ((x) ? "YES" : "NO")



typedef pair <int, int> ii;

typedef pair <int, ii> iii;



const int siz = 3e5 + 10;

const int SIZ = 1e6 + 10;

const int mod = 1e9 + 7;

const int maxx = 2e9;

const int MAXX = 1e18;

const string file = "2";



int a[siz];

int mxl[siz], mnr[siz];



int32_t main() {

    ios::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



//    freopen ((file + ".inp").c_str(), "r", stdin);

//    freopen ((file + ".out").c_str(), "w", stdout);



    int n;

    cin >> n;



    for (int i = 1; i <= 3 * n; i++) {

        cin >> a[i];

    }



    int suml = 0;

    priority_queue <int, vector <int>, greater <int> > pql;

    for (int i = 1; i <= n; i++) {

        suml += a[i];

        pql.push(a[i]);

    }



    mxl[n] = suml;

    for (int i = n + 1; i <= 2 * n; i++) {

        pql.push(a[i]);

        suml += a[i];

        suml -= pql.top();

        pql.pop();

        mxl[i] = suml;

    }



    int sumr = 0;

    priority_queue <int> pqr;

    for (int i = 2 * n + 1; i <= 3 * n; i++) {

        sumr += a[i];

        pqr.push(a[i]);

    }



    mnr[2 * n + 1] = sumr;

    for (int i = 2 * n; i >= n + 1; i--) {

        pqr.push(a[i]);

        sumr += a[i];

        sumr -= pqr.top();

        pqr.pop();

        mnr[i] = sumr;

    }



    int ans = -MAXX;

    for (int i = n; i <= 2 * n; i++) {

        ans = max(ans, mxl[i] - mnr[i + 1]);

    }



    cout << ans << "\n";



//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



    return 0;

}


// Fastest known solution for this problem: