main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ai <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ show $ ans ai

ans :: [Int] -> Int
ans ai = (\(a,b,c,d) -> if b == 1 then d-2*a else d) $ foldl func (10^5+1,0,False,0) ai where
  func (mi,minusN,if0,sumabs) k
    | k == 0 || if0 = (mi,0,True,sumabs + abs k)
    | k < 0 = (min mi (abs k),mod (1+minusN) 2,if0,sumabs + abs k)
    | otherwise = (min mi k,minusN,if0,sumabs + abs k)