// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

const int N = 300003;

const long long infll = 1000000000000000000;

int arr[N];

long long lef[N], righ[N];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i = 0;i<3*n;i++)

        scanf("%d",&arr[i]);

    for(int i = 0;i<N;i++)

        lef[i] = -infll, righ[i] = infll;

    long long sum = 0;

    multiset<int> s;

    for(int i = 0;i<3*n;i++) {

        s.insert(arr[i]);

        sum += arr[i];

        if(s.size() == n) {

            lef[i] = sum;

        } else if(s.size() > n) {

            sum -= *s.begin();

            s.erase(s.begin());

            lef[i] = sum;

        }

    }

    s.clear();

    sum = 0;

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

        sum += arr[i];

        s.insert(arr[i]*-1);

        if(s.size() == n) {

            righ[i] = sum;

        } else if (s.size() > n) {

            sum -= *(s.begin()) * -1;

            s.erase(s.begin());

            righ[i] = sum;

        }

    }

    for(int i = 1;i<N;i++)

        lef[i] = max(lef[i],lef[i-1]);

    for(int i = N-2;i>=0;i--)

        righ[i] = min(righ[i], righ[i+1]);

    long long ans = -infll;

    for(int i = 0;i<3*n;i++)

        ans = max(ans,lef[i] - righ[i+1]);

    printf("%lld",ans);

    return 0;

}


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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define SZ(a) int((a).size())

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

#define debug(x) cerr << #x << ": " << x << endl

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };



/* -----  2017/11/22  Problem: 074_arc_b / Link: __CONTEST_URL__  ----- */

/* ------問題------







-----問題ここまで----- */

/* -----解説等-----







----解説ここまで---- */



LL N;



LL ans = 0LL;



int main() {

	cin.tie(0);

	ios_base::sync_with_stdio(false);



	cin >> N;

	VL a(N * 3, 0);



	FOR(i, 0, N * 3) {

		cin >> a[i];

	}



	priority_queue<LL, VL, greater<LL>>pq;





	LL sum = 0;

	VL dp1(3 * N, 0);

	FOR(i, 0, 2 * N) {

		pq.push(a[i]);

		sum += a[i];

		if (SZ(pq) > N) {

			sum -= pq.top();pq.pop();

		}

		dp1[i] = sum;



	}



	sum = 0;

	VL dp2(3 * N, 0);

	priority_queue<LL>pq2;

	FORR(i, 3 * N - 1, N - 1) {

		pq2.push(a[i]);

		sum += a[i];

		if (SZ(pq2) > N) {

			sum -= pq2.top(); pq2.pop();

		}

		dp2[i] = sum;

	}

	ans = -1e18;

	FOR(i, N - 1, 2 * N) {

		ans = max(ans, dp1[i] - dp2[i + 1]);

	}

	cout << ans << "\n";



	return 0;

}