main=do
 n<-readLn;a<-map read.words<$>getLine
 print(min(f n a 1 0 0)(f n a (-1) 0 0))
  where f n a b s i |n==0 =i
                    |b==1&&(s+(head a))<=0    =f (n-1) (tail a) (-1) 1 (i+1-(s+(head a)))
                    |b==(-1)&&(s+(head a))>=0 =f (n-1) (tail a) 1 (-1) (i+1+(s+(head a)))
                    |otherwise                =f (n-1) (tail a) (-1*b) (s+(head a)) i