import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    //前半
    val first = fun(): LongArray {
    	val array = LongArray(N + 1)
    	val Q = PriorityQueue<Long>(N)
    	Q.addAll(A.subList(0, N))
    	var S = Q.toList().sum()
    	for (n in 0 .. N) {
        	array[n] = S
        	S += A[N + n]
        	Q.add(A[N + n])
        	S -= Q.poll()!! //一番小さい引く
    	}
    	return array
	}()
    //後半
    val latter = fun(): LongArray {
	    val array = LongArray(N + 1)
    	val Q = PriorityQueue<Long>(N, compareByDescending { it })
    	Q.addAll(A.subList(2 * N, 3 * N))
    	var S = Q.toList().sum()
    	for (n in 0 .. N) {
        	array[N - n] = S
        	S += A[2 * N - n - 1]
        	Q.add(A[2 * N - n - 1])
        	S -= Q.poll()!! // 一番大きい引く
    	}
    	return array
    }()
    var ans = (0 .. N).map { first[it] - latter[it] }.max()!!
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}
