main = do
  getLine
  as <- map read . words <$> getLine
  print (sq as)

sq as = min (count 0 0 aas1) (count 0 0 aas2)
  where
    aas = scanl1 (+) as
    aas1 = zip aas (cycle [1,-1])
    aas2 = zip aas (cycle [-1,1])

count acc _ [] = acc
count acc d ((a,s):as)
  | signum (a + d) == s = count acc d as
  | otherwise = let r = s * (abs (a + d) + 1) in count (acc + abs r) (d + r) as