module S = Set.Make(struct type t = int * int let compare = compare end)

let rec for_fold a b f v = if a >= b then v else for_fold (a+1) b f (f v a)

let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init (3*n) (fun _ -> Scanf.scanf " %d" ((+) 0)) in

  let s1 = for_fold 0 n (fun s i -> s + a.(i)) 0 in
  let st1 = for_fold 0 n (fun st i -> S.add (a.(i), i) st) S.empty in

  let s2 = for_fold (2*n) (3*n) (fun s i -> s + a.(i)) 0 in
  let st2 = for_fold (2*n) (3*n) (fun st i -> S.add (a.(i), i) st) S.empty in

  let l1 = for_fold n (2*n) (fun (m,ac,st) i ->
    let st' = S.add (a.(i), i) st in
    let le, j = S.min_elt st' in
    let st'' = S.add (a.(i),i) st' |> S.remove (le, j) in
    let m' = m + (a.(i) - le) in
    (m', m'::ac, st'')) (s1, [s1], st1)
    |> fun (_,l,_) -> List.rev l
  in

  let l2 = for_fold 0 n (fun (m,ac,st) i' ->
    let i = 2*n - 1 - i' in
    let st' = S.add (a.(i), i) st in
    let ma, j = S.max_elt st' in
    let st'' = S.add (a.(i),i) st' |> S.remove (ma, j) in
    let m' = m + (a.(i) - ma) in
    (m', m'::ac, st'')) (s2, [s2], st2)
    |> fun (_,l,_) -> l
  in

  List.combine l1 l2
  |> List.fold_left (fun v (a,b) ->
      max v (a-b)) (-s1-s2)
  |> Printf.printf "%d\n"