// 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.68978028679729x):
/*

 * Author : Andrew J

*/

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define pb push_back

#define mp make_pair

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

#define rall(x) x.rbegin() , x.rend()

#define vz(x) x.size()

using ll = long long;

using ii = pair <ll , ll>;

void in(ll &x);

const ll N = 1e5 + 10;

const ll INF = 1e18 + 50;

const ll MOD = 1e9 + 7;

ll n;



int main() {

  in(n);

  vector <ll> v(3 * n + 1);

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

    in(v[i]);

  }



  vector <ll> pmax(3 * n + 1 , -INF), smin(3 * n + 2 , INF);

  {

    priority_queue <ll , vector <ll> , greater <ll>> pq;

    ll sum = 0;

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

      sum += v[i];

      pq.push(v[i]);

    }

    pmax[n] = sum;

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

      ll lowest = pq.top(); pq.pop();

      sum -= lowest;

      if (v[i] > lowest) {

        pq.push(v[i]);

        sum += v[i];

      } else {

        pq.push(lowest);

        sum += lowest;

      }

      pmax[i] = max(pmax[i - 1] , sum);

    }

  }

  {

    priority_queue <ll> pq;

    ll sum = 0;

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

      sum += v[i];

      pq.push(v[i]);

    }

    smin[n * 2 + 1] = sum;

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

      ll highest = pq.top(); pq.pop();

      sum -= highest;

      if (v[i] < highest) {

        pq.push(v[i]);

        sum += v[i];

      } else {

        pq.push(highest);

        sum += highest;

      }

      smin[i] = min(smin[i + 1] , sum);

    }

  }



  ll ans = -INF;

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

    ans = max(ans , pmax[i] - smin[i + 1]);

  }

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

  return 0;

}



void in(ll &x){

	bool neg = false;

	register ll c;

	x = 0;

	c = getchar();

	if(c == '-'){

		neg = true;

		c = getchar();

	}

	for (; c > 47 && c < 58; c = getchar())

	x = (x << 1) + (x << 3) + c - 48;

	if (neg) x *= -1;

}