import Data.List

main = do
  _ <- getLine
  as <- getLine >>= return . map read . words :: IO [Integer]

  print $ min (sum $ zipWith (\a b -> abs (a-b)) as (f 0 as 1)) (sum $ zipWith (\a b -> abs (a-b)) as (f 0 as (-1)))
  
  where
    f _ [] _ = []
    f sum (x:xs) sign
      | sign < 0 = if sum + x > 0 then x : f (sum+x) xs (-sign) else (1-sum) : f 1 xs (-sign)
      | sign > 0 = if sum + x < 0 then x : f (sum+x) xs (-sign) else (-1-sum) : f (-1) xs (-sign)
