#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 1e5 + 20;
int arr[maxn];
LL last[maxn], per[maxn];
priority_queue<int>que;
priority_queue<int, vector<int>, greater<int> >qq;
void work() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; ++i) {
        scanf("%d", arr + i);
    }
    LL sum = 0;
    for (int i = 3 * n; i >= 2 * n + 1; --i) {
        last[i] = (long long int)1e18;
        sum += arr[i];
        que.push(arr[i]);
    }
    last[2 * n + 1] = sum;
    for (int i = 2 * n; i >= 1; --i) {
        if (arr[i] >= que.top()) {
            last[i] = sum;
        } else {
            sum -= que.top();
            que.pop();
            sum += arr[i];
            que.push(arr[i]);
            last[i] = sum;
        }
    }
//    for (int i = 1; i <= 3 * n; ++i) {
//        printf("%d ", last[i]);
//    }
    sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += arr[i];
        qq.push(arr[i]);
        per[i] = (long long int) -1e18;
    }
    per[n] = sum;
    for (int i = n + 1; i <= 3 * n; ++i) {
        if (arr[i] <= qq.top()) {
            per[i] = sum;
        } else {
            sum -= qq.top();
            qq.pop();
            qq.push(arr[i]);
            sum += arr[i];
            per[i] = sum;
        }
    }
    LL ans = -2e18;
    for (int i = 1; i <= 3 * n - 1; ++i) {
        ans = max(ans, per[i] - last[i + 1]);
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}
