#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e18;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>a(3 * N);
	priority_queue<ll, vector<ll>, greater<ll>>minq;
	priority_queue<ll>maxq;
	ll sum1 = 0, sum2 = 0;
	ll ans = -INF;

	rep(i, 3 * N) {
		cin >> a[i];
		if (i < N ) {
			minq.push(a[i]);
			sum1 += a[i];
		}
		if (i >= N * 2) {
			maxq.push(a[i]);
			sum2 += a[i];
		}
	}
	vector<ll>suma(N+1), sumb(N+1);
	suma[0] = sum1; sumb[0] = sum2;
	rep(i, N) {
		minq.push(a[N + i]);
		sum1 += a[N + i];
		sum1 -= minq.top();
		suma[i+1] = sum1;
		minq.pop();
	}
	rep(i, N) {
		maxq.push(a[2 * N - 1 - i]);
		sum2 += a[2 * N - 1 - i];
		sum2 -= maxq.top();
		sumb[i+1] = sum2;
		maxq.pop();
	}
	rep(i, N+1) {
		ans = max(ans, suma[i] - sumb[N - i]);
	}
	cout << ans << "\n";
	return 0;
}