object Main extends App {
  import collection.mutable.PriorityQueue
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val As = Array.fill(3*N)(sc.nextInt)

  def f(xs: Array[Int], ys: Array[Int]): Array[Int] = {
    val pq = new PriorityQueue[Int]()(Ordering.Int.reverse) ++ xs
    ys.scanLeft(pq.sum) { (s, y) =>
      pq += y
      s + y - pq.dequeue}
  }

  val List(as1, as2, as3) = As.grouped(N).toList
  val ans = f(as1, as2).zip(f(as3.map(a => -a), as2.map(a => -a).reverse).reverse).map(t => t._1 + t._2).max
  println(ans)
}