p :: Int -> Int -> [Int] -> Int
p n x (y:[])
  | x + y >= 0 = n+x+y+1
  | otherwise = n
p n x (y:ys)
  | x + y >= 0 = m (n+x+y+1) (-1) ys
  | otherwise = m n (x+y) ys

m :: Int -> Int -> [Int] -> Int
m n x (y:[])
  | x + y <= 0 = n-(x+y)+1
  | otherwise = n
m n x (y:ys)
  | x + y <= 0 = p (n-(x+y)+1) 1 ys
  | otherwise = p n (x+y) ys

solve :: [Int] -> Int
solve (x:xs)
  | x < 0 = min (p (-x+1) 1 xs) (m 0 x xs)
  | x > 0 = min (p 0 x xs) (m (x+1) (-1) xs)
  | x == 0 = min (p 1 (x+1) xs) (m 1 (x-1) xs)

main = getContents >>= print . solve . map read . words . last . lines