import Control.Arrow
import Data.List

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

sol [[n],as] = maximum .
  fmap (uncurry (-) . (sum *** sum) . splitAt n) .
  filter ((==2*n) . length) $ subsequences as