n = int(eval(input()))

A = list(map(int,input().split()))

ans = 10**15



for i in [-1,1]:

    ansi,sum=0,0

    for a in A:

        sum+=a

        if sum*i<=0:

          ansi+=abs(sum-i)

          sum=i

        i*=-1

    ans=min(ans,ansi)

print(ans)
N = int(eval(input()))

A = list(map(int,input().split()))

ans = 10**15



for s in [1,-1]:

  cos = 0

  tot = 0

  

  for a in A:

    tot+=a

    if s*tot<=0:

      cos+=abs(tot-s)

      tot=s

    s*=-1

  

  ans=min(ans,cos)



print(ans)
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 10**15
for i in [-1, 1]:
    ansi, sum = 0, 0
    for a in A:
        sum += a
        if sum * i <= 0:
            ansi += abs(sum - i)
            sum = i
        i *= -1
    ans = min(ans, ansi)
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 10**15
for s in [1, -1]:
    cos = 0
    tot = 0
    for a in A:
        tot += a
        if s * tot <= 0:
            cos += abs(tot - s)
            tot = s
        s *= -1
    ans = min(ans, cos)
print(ans)

-n = int(eval(input())) +N = int(eval(input())) -for i in [-1, 1]: -    ansi, sum = 0, 0 +for s in [1, -1]: +    cos = 0 +    tot = 0 -        sum += a -        if sum * i <= 0: -            ansi += abs(sum - i) -            sum = i -        i *= -1 -    ans = min(ans, ansi) +        tot += a +        if s * tot <= 0: +            cos += abs(tot - s) +            tot = s +        s *= -1 +    ans = min(ans, cos)