import Data.List
import qualified Data.Set as S

main = do
 n <- readLn
 as <- map read . words <$> getLine
 print (n3 n as)
 
n3 n as = maximum (fsearch n q as2)
 where
  (as1,as2) = splitAt n as
  q = S.fromList (zip as1 [0..])

fsearch n q as = do
 let r0 = sum (map fst (S.elems q))
 k <- [0..n]
 let (rh,rl) = transfer (n-k) k (r0,q) as
 return (rh - rl)

transfer n' 0 (rh,q) as = let as' = drop n' (reverse (sort as)) in (rh, sum as')
transfer n' k (rh,q) (a:as) = transfer n' (k-1) (rh-vmin+a, S.insert (a,i) q') as
 where ((vmin,i),q') = S.deleteFindMin q
