import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
long binarySearch(long min, long max, bool delegate(long) f){
	if(!f(min)) return min - 1; if(f(max)) return max;
	long mid; while(max - min > 1){ mid = min + (max - min) / 2; if(f(mid)) min = mid; else max = mid; } return min;
	}

void main(){
	int n = read.to!int;
	long[] as = readln.split.map!(to!long).array;
	
	long[] sums1;
	{
		auto h = heapify(as[0 .. n].map!(x => -x).array);
		long[] sums = [as[0 .. n].reduce!"a + b"()];
		foreach(int i; n .. (n + n)){
			long k = h.front;
			h.removeFront;
			h.insert(-as[i]);
			sums ~= sums[$ - 1] + (k - (-as[i]));
			}
		sums1 = sums;
		}
	
	debug sums1.writeln;
	
	long[] sums2;
	{
		auto h = heapify(as[n * 2 .. $]);
		long[] sums = [as[n * 2 .. $].reduce!"a + b"()];
		foreach_reverse(int i; n .. (n + n)){
			long k = h.front;
			h.removeFront;
			h.insert(as[i]);
			sums ~= sums[$ - 1] - (k - as[i]);
			}
		sums2 = sums;
		}
	
	debug sums2.writeln;
	
	long ans = long.min;
	foreach(int i; 0 .. n + 1){
		if(sums1[i] - sums2[n - i] > ans) ans = sums1[i] - sums2[n - i];
		}
	
	ans.writeln;
	
	}