import Data.Maybe
import qualified Data.ByteString.Char8 as B
 
readInt = fst . fromJust . B.readInt

apply n f x = foldr ($) x (replicate n f)

main = do
 n <- readLn
 as <- map readInt . B.words <$> B.getLine
 let (as1,as23) = splitAt n as
 let (as2,as3) = splitAt n as23
 print (n3 n as1 as2 as3)
 
n3 n as1 as2 as3 = maximum (fsearch n q1 as2 q3)
 where
  q1 = foldr push Empty as1
  q3 = foldr push Empty (map negate as3)
 
fsearch n q1 as2 q3 = do
 k <- [0..n]
 let (rh,rl) = transfer (n-k) k q1 as2 q3
 return (rh - rl)
 
transfer n' 0 q1 as2 q3 = (sumh q1, negate (sumh (apply n' pop (foldr push q3 (map negate as2)))))
transfer n' k q1 (a:as2) q3 = transfer n' (k-1) (pop (push a q1)) as2 q3


data Heap a = Empty | Node a [Heap a] deriving (Show, Eq)

merge Empty h = h
merge h Empty = h
merge (Node x xs) (Node y ys)
  | x < y     = Node x (Node y ys : xs)
  | otherwise = Node y (Node x xs : ys)

mergeList []       = Empty
mergeList [x]      = x
mergeList (x:y:xs) = merge (merge x y) (mergeList xs)

push x h = merge (Node x []) h

pop (Node x xs) = mergeList xs

top (Node x xs) = x

sumh Empty = 0
sumh (Node x xs) = x + sum (map sumh xs)