import Control.Monad
import Data.List

pattern :: Int -> [[Int]]
pattern n
  | even n = let h = div n 2 in [replicate (h-1) (-2) ++ [-1, 1] ++ replicate (h-1) 2]
  | odd n = let h = div n 2 in [replicate (h-1) (-2) ++ [-1, -1] ++ replicate h 2, replicate h (-2) ++ [1, 1] ++ replicate (h-1) 2]

f n cs = maximum $ map (sum . zipWith (*) cs) (pattern n)

main = readLn >>= \n -> replicateM n readLn >>= print . f n . sort 