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] -> Int
solve n (x:xs) = min (m n x xs) (p n x xs)

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