// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VL = vector<ll>;
#define rp(i,n) for(int i=0;i<(n);++i)
#define NMAX 100000

int N;
VL A(3*NMAX);

void f(VL &V, ll sign){
	V[0] = A[0];
	priority_queue<int> que;
	que.push(sign*A[0]);
	for(int i=1; i<3*N; ++i){
		que.push(sign*A[i]);
		ll topA = 0;
		if(que.size() > N){
			topA = sign*que.top();
			que.pop();
		}
		V[i] += V[i-1] + A[i] - topA;
	}
}

int main(){
	cin>>N;
	rp(i, 3*N) cin>>A[i];

	VL F(3*N), B(3*N);
	f(F, -1L);
	reverse(A.begin(), A.begin()+3*N);
	f(B, 1L);

	ll maxfb = LLONG_MIN;
	rp(i, N+1){
		int f = N - 1 + i;
		int b = 3*N - 1 - N - i;
		maxfb = max(maxfb, F[f]-B[b]);
	}
	cout<< maxfb <<endl;
}