// Slower C++ solution:
///dit me set

///tao xai Fenwick Tree



#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;

}


// Faster C++ solution for the same problem (measured speedup: 4.671811273503675x):
#include<bits/stdc++.h>

#define int long long

using namespace std;

const int Sz = 3e5 + 5;

int a[Sz];

int b[Sz];

int c[Sz];

int n;

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

priority_queue<int,vector<int>, less<int> > q2;

int32_t main(){

    //freopen("inp.txt", "r", stdin);

    //freopen("out.txt", "w", stdout);

    cin >> n;

    for(int i = 1; i <= 3 * n; i++) cin >> a[i];

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

        b[i] = b[i - 1] + a[i];

        q1.push(a[i]);

    }

    int Sum = b[n];

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

        if(a[i] > q1.top()){

            Sum -= q1.top();

            Sum += a[i];

            q1.pop();

            q1.push(a[i]);

        }

        b[i] = Sum;

    }

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

        c[i] = c[i + 1] + a[i];

        q2.push(a[i]);

    }

    Sum = c[2 * n + 1];

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

        if(a[i] < q2.top()){

            Sum -= q2.top();

            Sum += a[i];

            q2.pop();

            q2.push(a[i]);

        }

        c[i] = Sum;

    }

    int res = -1e18;

    for(int i = n; i <= 2 * n; i++) res = max(res, b[i] - c[i + 1]);

    cout << res;

    return 0;

}