import java.util.*

fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
	val arr = readLine()!!.split(" ").map{ it.toLong() }.toLongArray()
	val comparator = Comparator<Pair<Long, Int>>{ a, b -> if (a.first != b.first) { a.first.compareTo(b.first) } else { a.second.compareTo(b.second) } }
	val fstSet = arr.sliceArray(0..(n - 1)).mapIndexed({i, v -> Pair(v, i)}).toSortedSet(comparator)
	val sndSet = arr.sliceArray(n..(3 * n - 1)).mapIndexed({i, v -> Pair(v, i + n)}).toSortedSet(comparator)
	val sndUnused = sortedSetOf<Pair<Long, Int>>(comparator)
	for (i in 1..n) {
		val p = sndSet.last()
		sndSet.remove(p)
		sndUnused.add(p)
	}
	var score = fstSet.fold(0L, {acc, p -> acc + p!!.first}) - sndSet.fold(0L, {acc, p -> acc + p!!.first})
	var ans = score
	for (i in n..(2 * n - 1)) {
		val p = fstSet.first()
		fstSet.remove(p)
		fstSet.add(Pair(arr[i], i))
		score -= p.first
		score += arr[i]
		if (sndSet.remove(Pair(arr[i], i))) {
			val p = sndUnused.first()
			sndUnused.remove(p)
			sndSet.add(p)
			score += arr[i]
			score -= p.first
		} else {
			sndUnused.remove(Pair(arr[i], i))
		}
		ans = Math.max(score, ans)
	}
	println(ans)	

}
