#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

//ここから編集する

int main() {

    int n;
    cin >> n;
    vector<ll> v;
    for (int i = 0; i < 3 * n; i++) {
        ll tmp;
        scanf("%d", &tmp);
        v.push_back(tmp);
    }

    int begin = 0;
    int end = 3 * n - 1;
    priority_queue<ll, vector<ll>, greater<ll>> minp;
    vector<ll> firstSum;
    firstSum.push_back(0);
    vector<ll> secoundSum;
    secoundSum.push_back(0);
    for (int i = 0; i < n; i++) {
        minp.push(v[begin]);
        firstSum[0] += v[begin];
        begin++;
    }
    priority_queue<ll, vector<ll>, less<ll>> maxp;
    for (int i = 0; i < n; i++) {
        maxp.push(v[end]);
        secoundSum[0] += v[end];
        end--;
    }
//    while (end - begin >= 0) {
//        int left = v[begin] - minp.top();
//        int right = maxp.top() - v[end];
//        if (left < 0 && right < 0) {
//            begin++;
//            end--;
//        } else if (left < right) {
//            maxp.pop();
//            maxp.push(v[end]);
//            end--;
//
//        } else {
//            minp.pop();
//            minp.push(v[begin]);
//            begin++;
//
//        }
//
//    }
    //前半の最大値を得る
    for(int i = n; i < 2 * n; i++){
        ll in = v[i];
        minp.push(in);
        ll out = minp.top();minp.pop();
        firstSum.push_back(firstSum[firstSum.size() - 1] + in - out);
    }
    //後半の最小値を得る
    for(int i = 2 * n - 1; i >= n; i--){
        ll in = v[i];
        maxp.push(in);
        ll out = maxp.top(); maxp.pop();
        secoundSum.push_back(secoundSum[secoundSum.size() - 1] + in - out);
    }
    reverse(secoundSum.begin(),secoundSum.end());
    ll ans = firstSum[0] - secoundSum[0];
    for(int i = 1; i <= n; i++){
        ll tmp = firstSum[i] - secoundSum[i];
        if(tmp > ans){
            ans = tmp;
        }
    }

    cout << ans << endl;



//    ll minsum = 0;
//    while(!minp.empty()) {
//        minsum += minp.top();minp.pop();
//    }
//
//    ll maxsum = 0;
//    while(!maxp.empty()) {
//        maxsum += maxp.top();maxp.pop();
//    }
//    cout << minsum - maxsum << endl;



    return 0;
}

Measured memory_bytes: 8428