import sys

input = sys.stdin.readline



n = int(eval(input()))

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



b = a[:]

acc = 0



for i in range(n):

    if i%2==0:

        if acc+b[i]<=0:

            b[i] += 1-(acc+b[i])

    else:

        if acc+b[i]>=0:

            b[i] -= acc+b[i]+1

    

    acc += b[i]



c = a[:]

acc = 0



for i in range(n):

    if i%2==0:

        if acc+c[i]>=0:

            c[i] -= acc+c[i]+1

    else:

        if acc+c[i]<=0:

            c[i] += 1-(acc+c[i])

    

    acc += c[i]



ans = min(sum(abs(ai-bi) for ai, bi in zip(a, b)), sum(abs(ai-ci) for ai, ci in zip(a, c)))



print(ans)
import sys

input = sys.stdin.readline



n = int(eval(input()))

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

cnt1, now = 0, 0



for i in range(n):

    now += a[i]

    

    if i%2==0:

        if now<=0:

            cnt1 += 1-now

            now = 1

    else:

        if now>=0:

            cnt1 += now+1

            now = -1

    

cnt2, now = 0, 0



for i in range(n):

    now += a[i]

    

    if i%2==1:

        if now<=0:

            cnt2 += 1-now

            now = 1

    else:

        if now>=0:

            cnt2 += now+1

            now = -1



print((min(cnt1, cnt2)))
import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = a[:]
acc = 0
for i in range(n):
    if i % 2 == 0:
        if acc + b[i] <= 0:
            b[i] += 1 - (acc + b[i])
    else:
        if acc + b[i] >= 0:
            b[i] -= acc + b[i] + 1
    acc += b[i]
c = a[:]
acc = 0
for i in range(n):
    if i % 2 == 0:
        if acc + c[i] >= 0:
            c[i] -= acc + c[i] + 1
    else:
        if acc + c[i] <= 0:
            c[i] += 1 - (acc + c[i])
    acc += c[i]
ans = min(
    sum(abs(ai - bi) for ai, bi in zip(a, b)), sum(abs(ai - ci) for ai, ci in zip(a, c))
)
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
cnt1, now = 0, 0
for i in range(n):
    now += a[i]
    if i % 2 == 0:
        if now <= 0:
            cnt1 += 1 - now
            now = 1
    else:
        if now >= 0:
            cnt1 += now + 1
            now = -1
cnt2, now = 0, 0
for i in range(n):
    now += a[i]
    if i % 2 == 1:
        if now <= 0:
            cnt2 += 1 - now
            now = 1
    else:
        if now >= 0:
            cnt2 += now + 1
            now = -1
print((min(cnt1, cnt2)))

-b = a[:] -acc = 0 +cnt1, now = 0, 0 +    now += a[i] -        if acc + b[i] <= 0: -            b[i] += 1 - (acc + b[i]) +        if now <= 0: +            cnt1 += 1 - now +            now = 1 -        if acc + b[i] >= 0: -            b[i] -= acc + b[i] + 1 -    acc += b[i] -c = a[:] -acc = 0 +        if now >= 0: +            cnt1 += now + 1 +            now = -1 +cnt2, now = 0, 0 -    if i % 2 == 0: -        if acc + c[i] >= 0: -            c[i] -= acc + c[i] + 1 +    now += a[i] +    if i % 2 == 1: +        if now <= 0: +            cnt2 += 1 - now +            now = 1 -        if acc + c[i] <= 0: -            c[i] += 1 - (acc + c[i]) -    acc += c[i] -ans = min( -    sum(abs(ai - bi) for ai, bi in zip(a, b)), sum(abs(ai - ci) for ai, ci in zip(a, c)) -) -print(ans) +        if now >= 0: +            cnt2 += now + 1 +            now = -1 +print((min(cnt1, cnt2)))