import qualified Data.IntSet as S
import Data.List

main = interact $ show . sol . fmap (fmap read . words) . lines

sol [[n],as] = maximum $ fmap f [n..2*n]
  where
  f k = sum l' - sum r'
    where
    (l,r) = splitAt k as
    l' = take n . S.toDescList $ S.fromList l
    r' = take n . S.toAscList $ S.fromList r
