import scala.collection.mutable
import scala.io.StdIn.readLine

object Main extends App {
  val n = readLine.toInt
  val a = readLine.split(" ").map(_.toLong)

  val sum1 = a.take(n).sum
  val sum2 = a.take(2 * n).sum - sum1
  val sum3 = a.sum - sum2 - sum1

  val formerQueue = mutable.PriorityQueue(a.take(n): _*)(implicitly[Ordering[Long]].reverse)

  val formerMap: mutable.Map[Int, Long] = mutable.HashMap.empty[Int, Long]
  formerMap.put(n - 1, sum1)

  for(i <- 0 until n) {
    val j = n + i
    formerQueue.enqueue(a(j))
    val min = formerQueue.dequeue()
    formerMap.put(j, formerMap(j - 1) + a(j) - min)
  }

  val latterQueue = mutable.PriorityQueue(a.takeRight(n): _*)

  val latterMap = mutable.HashMap.empty[Int, Long]
  latterMap.put(2 * n, sum3)

  for(i <- 0 until n) {
    val j = 2 * n - 1 - i
    latterQueue.enqueue(a(j))
    val max = latterQueue.dequeue()
    latterMap.put(j, latterMap(j + 1) + a(j) - max)
  }

  val ans = (for(i <- 0 to n) yield {
    val j = n - 1 + i
    formerMap(j) - latterMap(j + 1)
  }).max

  println(ans)

}