object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = Array.fill(3*n)(sc.nextLong())

  val h1 = new BinaryHeap[Long](n+1, _ < _)
  val sums1 = Array.fill(n+1)(0L)
  var sum1 = 0L
  for (a <- as.take(n)) {
    sum1 += a
    h1.add(a)
  }
  sums1(0) = sum1

  for ((a, i) <- as.slice(n, 2*n).zipWithIndex) {
    sum1 += a
    h1.add(a)
    sum1 -= h1.pop()
    sums1(i+1) = sum1
  }

  val h2 = new BinaryHeap[Long](n+1, _ > _)
  val sums2 = Array.fill(n+1)(0L)
  var sum2 = 0L
  for (a <- as.takeRight(n)) {
    sum2 += a
    h2.add(a)
  }
  sums2(0) = sum2

  for ((a, i) <- as.slice(n, 2*n).reverse.zipWithIndex) {
    sum2 += a
    h2.add(a)
    sum2 -= h2.pop()
    sums2(i+1) = sum2
  }

  val ans = sums1.zip(sums2.reverse).map{case (s1, s2) => s1 - s2}.max

  println(ans)
}

class BinaryHeap[A: scala.reflect.ClassTag](maxSize: Int, comparator: (A, A) => Boolean) {
  private val heap = Array.ofDim[A](maxSize)

  var size = 0
  def isEmpty: Boolean = size == 0
  def nonEmpty: Boolean = !isEmpty

  private def par(idx: Int): Int = (idx - 1) / 2
  private def left(idx: Int): Int = 2 * idx + 1
  private def right(idx: Int): Int = 2 * idx + 2

  private def isRoot(idx: Int): Boolean = idx == 0
  private def hasLeft(idx: Int): Boolean = left(idx) < size
  private def hasRight(idx: Int): Boolean = right(idx) < size

  private def swap(i: Int, j: Int): Unit = {
    val t = heap(i)
    heap(i) = heap(j)
    heap(j) = t
  }

  private def upHeap(idx: Int): Unit = {
    if (!isRoot(idx) && comparator(heap(idx), heap(par(idx)))) {
      swap(idx, par(idx))
      upHeap(par(idx))
    }
  }

  private def downHeap(idx: Int): Unit = {
    if (hasLeft(idx)) {
      val t = if (hasRight(idx) && comparator(heap(right(idx)), heap(left(idx)))) {
        right(idx)
      } else {
        left(idx)
      }
      if (comparator(heap(t), heap(idx))) {
        swap(idx, t)
        downHeap(t)
      }
    }
  }

  def add(a: A): Unit = {
    size += 1
    heap(size - 1) = a
    upHeap(size - 1)
  }

  def pop(): A = {
    val head = heap(0)
    heap(0) = heap(size - 1)
    size -= 1
    downHeap(0)
    head
  }
}
