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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int MAXN = 3 * N;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

ll a[MAXN], b[MAXN], inp[MAXN];

struct Info {
    ll sum, idx, val;
}t[4 * MAXN];

void Merge(int p, int q, int r, int what){
    t[p].sum = t[q].sum + t[r].sum;
    if(what == 0){
        if(t[q].val <= t[r].val){
            t[p].val = t[q].val;
            t[p].idx = t[q].idx;
        }else {
            t[p].val = t[r].val;
            t[p].idx = t[r].idx;
        }
    }else {
        if(t[q].val >= t[r].val){
            t[p].val = t[q].val;
            t[p].idx = t[q].idx;
        }else {
            t[p].val = t[r].val;
            t[p].idx = t[r].idx;
        }
    }
}

void build(int x, int b, int e, int what){
    if(b == e){
        t[x].sum = inp[b];
        t[x].val = inp[b];
        t[x].idx = b;
        return ;
    }
    int m = (b + e) >> 1;
    build(x + x, b, m, what);
    build(x + x + 1, m + 1, e, what);
    Merge(x, x + x, x + x + 1, what);
}

pii get_min(int x, int b, int e, int l, int r){
    if(b > r || e < l) return mp(1e9 + 5, 0);
    if(b >= l && e <= r){
        return mp(t[x].val, t[x].idx);
    }
    int m = (b + e) >> 1;
    pii xx = get_min(x + x, b, m, l, r);
    pii yy = get_min(x + x + 1, m + 1, e, l, r);
    if(yy.first < xx.first){
        xx = yy;
    }
    return xx;
}

pii get_max(int x, int b, int e, int l, int r){
    if(b > r || e < l) return mp(0, 0);
    if(b >= l && e <= r){
        return mp(t[x].val, t[x].idx);
    }
    int m = (b + e) >> 1;
    pii xx = get_max(x + x, b, m, l, r);
    pii yy = get_max(x + x + 1, m + 1, e, l, r);
    if(yy.first > xx.first){
        xx = yy;
    }
    return xx;
}

void modify(int x, int b, int e, int l, int r, int what){
    if(b > r || e < l) return ;
    if(b >= l && e <= r){
        if(what == 0){
            t[x].sum = 0;
            t[x].val = 1e9 + 5;
        }else {
            t[x].sum = 0;
            t[x].val = 0;
        }
        return ;
    }
    int m = (b + e) >> 1;
    modify(x + x, b, m, l, r, what);
    modify(x + x + 1, m + 1, e, l, r, what);
    Merge(x, x + x, x + x + 1, what);
}

ll get_sum(int x, int b, int e, int l, int r){
    if(b > r || e < l) return 0;
    if(b >= l && e <= r){
        return t[x].sum;
    }
    int m = (b + e) >> 1;
    return get_sum(x + x, b, m, l, r) +
           get_sum(x + x + 1, m + 1, e, l, r);
}

int main(){
    int n = in();
    for(int i = 1; i <= n + n + n; i++){
        inp[i] = lin();
    }
    build(1, 1, MAXN, 0);
    a[n] = get_sum(1, 1, MAXN, 1, n);
    for(int i = n + 1; i <= n + n; i++){
        pii x = get_min(1, 1, MAXN, 1, i);
        modify(1, 1, MAXN, x.se, x.se, 0);
        a[i] = get_sum(1, 1, MAXN, 1, i);
    }

    build(1, 1, MAXN, 1);
    b[n + n + 1] = get_sum(1, 1, MAXN, n + n + 1, n * 3);
    for(int i = n + n; i >= n; i--){
        pii x = get_max(1, 1, MAXN, i, 3 * n);
        modify(1, 1, MAXN, x.se, x.se, 1);
        b[i] = get_sum(1, 1, MAXN, i, 3 * n);
    }

    ll ans = -1ll * 1e18;
    for(int i = n; i <= n + n; i++){
        ans = max(ans, a[i] - b[i+1]);
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 35072