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 (as2a,as2b) = splitAt k as2
 let q1' = foldr push q1 as2a
 let q3' = foldr push q3 (map negate as2b)
 let rh = sumh (apply k  pop q1')
 let rl = negate (sumh (apply (n-k) pop q3'))
 return (rh - rl)


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 _ xs) = mergeList xs

top (Node x _) = x

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