CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

x = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i & 1 == 0:
        if tmp < 1:
            x += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            x += 1+tmp
            tmp = -1
y = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i & 1:
        if tmp < 1:
            y += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            y += 1+tmp
            tmp = -1
print((min(x,y)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

def check(flag):
    acc = 0
    cnt = 0

    flag = flag
    for i in a:
        acc += i
        if (flag == 1 and flag > acc) or (flag == -1 and flag < acc) or i == 0:
            cnt += abs(flag - acc)
            acc = flag
        flag *= -1
    return cnt

print((min(check(1), check(-1))))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))


# プラススタート ------------------
ans01 = 0
temp = a[0]
if (temp > 0):
    pass
else:
    add = abs(temp) + 1
    ans01 += add
    temp = 1

for i in range(1, n):
    tar = temp + a[i]
    if (tar * temp < 0):
        temp = tar
    else:
        add = abs(tar) + 1
        ans01 += add
        if (temp > 0):
            temp = -1
        else:
            temp = 1
    #print(tar, ans)
# マイナススタート ------------------
ans02 = 0
temp = a[0]
if (temp < 0):
    pass
else:
    add = abs(temp) + 1
    ans02 += add
    temp = -1

for i in range(1, n):
    tar = temp + a[i]
    if (tar * temp < 0):
        temp = tar
    else:
        add = abs(tar) + 1
        ans02 += add
        if (temp > 0):
            temp = -1
        else:
            temp = 1
    #print(tar, ans)

ans = min(ans01, ans02)

print(ans)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))


def calc(val):
    # valには、１か−１を入れる。
    if (val * a[0] > 0):
        # 狙った符号のパターン
        temp = a[0]
        ans01 = 0

    else:
        # 違うパターン
        add = abs(a[0]) + 1
        ans01 = add
        temp = val

    for i in range(1, n):
        tar = temp + a[i]
        if (tar * temp < 0):
            temp = tar
        else:
            add = abs(tar) + 1
            ans01 += add
            if (temp > 0):
                temp = -1
            else:
                temp = 1

    return ans01


ans = min(calc(1), calc(-1))


print(ans)
# Original solution
import sys

def solve():
    n = int(eval(input()))
    a = [int(i) for i in input().split()]

    ans1 = 0 if a[0] > 0 else abs(a[0] - 1)
    v = a[0] if a[0] > 0 else 1

    for i in range(1, n):
        if v * (v + a[i]) < 0:
            v += a[i]
        else:
            if v > 0:
                ans1 += abs(v + a[i] + 1)
                v = -1
            else:
                ans1 += abs(v + a[i] - 1)
                v = 1

    ans2 = 0 if a[0] < 0 else abs(a[0] + 1)
    v = a[0] if a[0] < 0 else -1

    for i in range(1, n):
        if v * (v + a[i]) < 0:
            v += a[i]
        else:
            if v > 0:
                ans2 += abs(v + a[i] + 1)
                v = -1
            else:
                ans2 += abs(v + a[i] - 1)
                v = 1

    ans = min(ans1, ans2)

    print(ans)

if __name__ == '__main__':
    solve()

# Optimized solution
import sys

def solve():
    n = int(eval(input()))
    a = [int(i) for i in input().split()]

    ans1 = scan(a, -1)
    ans2 = scan(a, 1)

    ans = min(ans1, ans2)

    print(ans)

def scan(a, sgn):
    if a[0] * sgn > 0:
        res = 0
        v = a[0]
    else:
        res = abs(a[0] - sgn)
        v = sgn

    for ai in a[1:]:
        if v * (v + ai) < 0:
            v += ai
        else:
            if v > 0:
                res += abs(v + ai + 1)
                v = -1
            else:
                res += abs(v + ai - 1)
                v = 1

    return res

if __name__ == '__main__':
    solve()
# Original solution
n = int(eval(input()))

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

ans = 0
cnt = 0
s = 0

for i in range(n):
    if i == 0:
        ans += li[i]
        if ans > 0:
            s = 1
        else:
            s = -1
    else:
        ans += li[i]
        if ans <= 0 and s == -1:
            while True:
                ans += 1
                cnt += 1
                if ans > 0:
                    s == 1
                    break
        if ans >= 0 and s == 1:
            while True:
                ans -= 1
                cnt += 1
                if ans < 0:
                    s == -1
                    break
        s *= -1

print(cnt)

# Optimized solution
n = int(eval(input()))

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

ans = 0
cnt = 0

s = 1
for i in range(n):
    ans += li[i]
    if ans <= 0 and s == -1:
        cnt += abs(ans) + 1
        ans = 1
    if ans >= 0 and s == 1:
        cnt += abs(ans) + 1
        ans = -1
    s *= -1
    
res1 = cnt


ans = 0
cnt = 0

    
s = -1
for i in range(n):
    ans += li[i]
    if ans <= 0 and s == -1:
        cnt += abs(ans) + 1
        ans = 1
    if ans >= 0 and s == 1:
        cnt += abs(ans) + 1
        ans = -1
    s *= -1
    
res2 = cnt

print((min(res1,res2)))
# Original solution
import copy

n=int(eval(input()))
a=[int(x) for x in input().rstrip().split()]
ac=copy.deepcopy(a)

now=0
ans1=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if now<=0:
      ans1+=abs(now)+1
      now=1
  else:
    if 0<=now:
      ans1+=abs(now)+1
      now=-1

now=0
ans2=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if 0<=now:
      ans2+=abs(now)+1
      now=-1
  else:
    if now<=0:
      ans2+=abs(now)+1
      now=1
print((min(ans1,ans2)))

# Optimized solution
import copy

n=int(eval(input()))
a=[int(x) for x in input().rstrip().split()]

now=0
ans1=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if now<=0:
      ans1+=abs(now)+1
      now=1
  else:
    if 0<=now:
      ans1+=abs(now)+1
      now=-1

now=0
ans2=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if 0<=now:
      ans2+=abs(now)+1
      now=-1
  else:
    if now<=0:
      ans2+=abs(now)+1
      now=1
print((min(ans1,ans2)))
# Original solution
n = int(eval(input()))
a_list = list(map(int, input().split()))

total = 0
count = 0
pos_or_neg = True  # True = +, False = -

if sum(a_list) >= 0:
    if n % 2 == 0:
        pos_or_neg = False
    else:
        pos_or_neg = True
else:
    if n % 2 == 0:
        pos_or_neg = True
    else:
        pos_or_neg = False

for a in a_list:
    total += a
    if pos_or_neg:
        while total <= 0:
            total += 1
            count += 1
        pos_or_neg = False

    else:
        while total >= 0:
            total -= 1
            count += 1
        pos_or_neg = True

print(count)

# Optimized solution
n = int(eval(input()))
a_list = list(map(int, input().split()))

total = 0
count = 0
pos_or_neg = True  # True = +, False = -

for a in a_list:
    total += a
    if pos_or_neg:
        if total <= 0:
            count += -total + 1
            total += -total + 1
        pos_or_neg = False

    else:
        if total >= 0:
            count += total + 1
            total -= total + 1
        pos_or_neg = True

first_count = count
count = 0
total = 0
pos_or_neg = False

for a in a_list:
    total += a
    if pos_or_neg:
        if total <= 0:
            count += -total + 1
            total += -total + 1
        pos_or_neg = False

    else:
        if total >= 0:
            count += total + 1
            total -= total + 1
        pos_or_neg = True

print((min(count, first_count)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

sum = a[0]
count = 0

for i in range(1, n) :
    temp = sum
    sum += a[i]
    if temp > 0 and sum > 0 :
        while sum >= 0 :
            count += 1
            sum -= 1
    elif temp < 0 and sum < 0 :
        while sum <= 0 :
            count += 1
            sum += 1

if sum == 0 :
    count += 1

print(count)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

sum = a[0]
count1 = 0
count2 = 0

sum1 = 0
sum2 = 0

for i in range(n) :
    sum1 += a[i]
    sum2 += a[i]
    if i % 2 == 0 :
        if sum1 >= 0 :
            count1 += abs(sum1) + 1
            sum1 = -1
        if sum2 <= 0 :
            count2 += abs(sum2) + 1
            sum2 = 1
    elif i % 2 == 1 :
        if sum1 <= 0 :
            count1 += abs(sum1) + 1
            sum1 = 1
        if sum2 >= 0 :
            count2 += abs(sum2) + 1
            sum2 = -1

print((min(count1, count2)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
A = [n for n in a]

cnt1 = 0
cnt2 = 0
S = 0

if a[0] > 0:
    for i in range(n-1):
        S += a[i]
        if a[i] > 0:
            while S + a[i+1] >= 0:
                a[i+1] -= 1
                cnt1 += 1
        elif a[i] < 0:
            while S + a[i+1] <= 0:
                a[i+1] += 1
                cnt1 += 1
    A[0] = -1
    cnt2 = a[0] + 1
    for i in range(n-1):
        S += A[i]
        if A[i] > 0:
            while S + A[i+1] >= 0:
                A[i+1] -= 1
                cnt2 += 1
        elif A[i] < 0:
            while S + A[i+1] <= 0:
                A[i+1] += 1
                cnt2 += 1
elif a[0] < 0:
    for i in range(n-1):
        S += a[i]
        if a[i] > 0:
            while S + a[i+1] >= 0:
                a[i+1] -= 1
                cnt1 += 1
        elif a[i] < 0:
            while S + a[i+1] <= 0:
                a[i+1] += 1
                cnt1 += 1
    A[0] = 1
    cnt2 = -a[0] + 1
    for i in range(n-1):
        S += A[i]
        if A[i] > 0:
            while S + A[i+1] >= 0:
                A[i+1] -= 1
                cnt2 += 1
        elif A[i] < 0:
            while S + A[i+1] <= 0:
                A[i+1] += 1
                cnt2 += 1
else:
    a[0] = 1
    cnt1 = 1
    for i in range(n-1):
        S += a[i]
        if a[i] > 0:
            while S + a[i+1] >= 0:
                a[i+1] -= 1
                cnt1 += 1
        elif a[i] < 0:
            while S + a[i+1] <= 0:
                a[i+1] += 1
                cnt1 += 1
    A[0] = -1
    cnt2 = 1
    for i in range(n-1):
        S += A[i]
        if A[i] > 0:
            while S + A[i+1] >= 0:
                A[i+1] -= 1
                cnt2 += 1
        elif A[i] < 0:
            while S + A[i+1] <= 0:
                A[i+1] += 1
                cnt2 += 1
cnt = cnt2 if cnt1 >= cnt2 else cnt1

print(cnt)


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

S1 = 0
S2 = 0
#S1が奇数番目が正の場合、S2が偶数番目が負の場合
cnt1 = 0
cnt2 = 0

for i,num in enumerate(a):
    S1 += num
    if i % 2 == 0 and S1 <= 0:
        cnt1 += 1 - S1
        S1 = 1
    if i % 2 != 0 and S1 >= 0:
        cnt1 += 1 + S1
        S1 = -1

    S2 += num
    if i % 2 == 0 and S2 >= 0:
        cnt2 += 1 + S2
        S2 = -1
    if i % 2 != 0 and S2 <= 0:
        cnt2 += 1 - S2
        S2 = 1

print((cnt1 if cnt1 <= cnt2 else cnt2))
# Original solution
n = int(eval(input()))
a = tuple(list(map(int, input().split())))
#aをtupleにしておかないとb = aとしたときにb変更するとa変更されてしまう リストーのコピー
def puramai(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans

def maipura(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans
print((min(maipura(a), puramai(a))))

# Optimized solution
N = int(eval(input()))
a = [int(i) for i in input().split()]
 
def pura(a):
    A = a[:]
    ans = 0
    check = 0
    if A[0] <= 0:
        ans += 1 + abs(A[0])
        A[0] = 1
        
    check += A[0]
    
    for i in range(1, N):
        if i % 2 != 0:
            if check + A[i] >= 0:
                ans += abs(A[i] + 1 + check)
                A[i] = -1 - check
        else:
            if check + A[i] <= 0:
                ans += abs(A[i] - (1 - check))
                A[i] = 1 - check
        check += A[i]
    return ans
 
def mai(a):
    A = a[:]
    ans = 0
    check = 0
    if A[0] >= 0:
        ans +=1 + abs(A[0])
        A[0] = -1
        
    check += A[0]
    
    for i in range(1, N):
        if i % 2 != 0:
            if check + A[i] <= 0:
                ans += abs(A[i] - (1 - check))
                A[i] = 1 - check
        else:
            if check + A[i] >= 0:
                ans += abs(A[i] +( 1 + check))
                A[i] = -1 - check
        check += A[i]
    return ans
print((min(pura(a), mai(a))))
# Original solution
n = int(eval(input()))

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

import itertools
alsum = list(itertools.accumulate(al))

temp1 = 0
temp2 = 0
for i in range(n):
    if i % 2 ==0:
        if alsum[i] >0:
            pass
        else:
            y = abs(alsum[i])+1
            temp1 += y
            alsum = list([x +y for x in alsum])
    else:
        if alsum[i] <0:
            pass
        else:
            y = alsum[i]+1
            temp1 += y
            alsum = list([x-y for x in alsum])
    
import itertools
alsum = list(itertools.accumulate(al))

for j in range(n):
    if j % 2 ==0:
        if alsum[j] <0:
            pass
        else:
            y = abs(alsum[j])+1
            temp2 += y
            alsum = list([x-y for x in alsum])
    else:
        if alsum[j] >0:
            pass
        else:
            y = abs(alsum[j])+1
            temp2 += y
            alsum = list([x+y for x in alsum])

print((min(temp1,temp2)))

# Optimized solution
n = int(eval(input()))

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

import itertools
alsum = list(itertools.accumulate(al))

temp1 = 0
temp2 = 0
res = 0
for i in range(n):
    res += al[i]
    if i % 2 ==0:
        if res >0:
            pass
        else:
            y = res*(-1)+1
            temp1 += y
            res =1
    else:
        if res <0:
            pass
        else:
            y = res+1
            temp1 += y
            res = -1
    
res= 0

for j in range(n):
    res += al[j]
    if j % 2 ==0:
        if res <0:
            pass
        else:
            y = res+1
            temp2 += y
            res = -1
    else:
        if res >0:
            pass
        else:
            y = res*(-1)+1
            temp2 += y
            res = 1

print((min(temp1,temp2)))
# Original solution
from itertools import accumulate
n, *A = list(map(int, open(0).read().split()))
B = list(accumulate(A))
p0 = n0 = p1 = n1 = 0
for i, b in enumerate(B):
    if i % 2 == 0:
        if b+p0-n0 <= 0:
            p0 += abs(b+p0-n0)+1
        if b+p1-n1 >= 0:
            n1 += abs(b+p1-n1)+1
    else:
        if b+p0-n0 >= 0:
            n0 += abs(b+p0-n0)+1
        if b+p1-n1 <= 0:
            p1 += abs(b+p1-n1)+1
print((min(p0+n0, p1+n1)))


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

def calc(t):
  ans = su = 0
  for i in range(n):
    su += a[i]
    if i % 2 == t:
      if su > 0:
        pass
      else:
        x = 1 - su
        ans += abs(x)
        su = 1
    else:
      if su < 0:
        pass
      else:
        x = - 1 - su
        ans += abs(x)
        su = -1
  return ans
print((min(calc(1), calc(0))))
# Original solution
n = int(eval(input()))
a = [int(_) for _ in input().split()]
new_a_plus = [a[i] for i in range(n)]
new_a_minus = [a[i] for i in range(n)]

count_plus = 0
if a[0] <= 0:
    new_a_plus[0] = 1
    count_plus += 1 - a[0]

for i in range(1, n):
    if i % 2 == 0:
        if sum(new_a_plus[:i+1]) <= 0:
            new_a_plus[i] = -sum(new_a_plus[:i])+1
            count_plus += new_a_plus[i] - a[i]
    else:
        if sum(new_a_plus[:i+1]) >= 0:
            new_a_plus[i] = -sum(new_a_plus[:i])-1
            count_plus += a[i] - new_a_plus[i]

count_minus = 0
if a[0] >= 0:
    new_a_minus[0] = -1
    count_minus += a[0] + 1

for i in range(1, n):
    if i % 2 == 0:
        if sum(new_a_minus[:i+1]) >= 0:
            new_a_minus[i] = -sum(new_a_minus[:i])-1
            count_minus += a[i] - new_a_minus[i]
    else:
        if sum(new_a_minus[:i+1]) <= 0:
            new_a_minus[i] = -sum(new_a_minus[:i])+1
            count_minus += new_a_minus[i] - a[i]

print((min(count_plus, count_minus)))

# Optimized solution
n = int(eval(input()))
a = [int(_) for _ in input().split()]
new_a_plus = [a[i] for i in range(n)]
new_a_minus = [a[i] for i in range(n)]

count_plus = 0
now_total_plus = 0

for i in range(0, n):
    if i % 2 == 0:
        if now_total_plus + a[i] <= 0:
            new_a_plus[i] = - now_total_plus + 1
            count_plus += new_a_plus[i] - a[i]
    else:
        if now_total_plus + a[i] >= 0:
            new_a_plus[i] = - now_total_plus - 1
            count_plus += a[i] - new_a_plus[i]
    now_total_plus += new_a_plus[i]

count_minus = 0
now_total_minus = 0

for i in range(0, n):
    if i % 2 == 0:
        if now_total_minus + a[i] >= 0:
            new_a_minus[i] = - now_total_minus - 1
            count_minus += a[i] - new_a_minus[i]
    else:
        if now_total_minus + a[i] <= 0:
            new_a_minus[i] = - now_total_minus + 1
            count_minus += new_a_minus[i] - a[i]
    now_total_minus += new_a_minus[i]

print((min(count_plus, count_minus)))
# Original solution
from copy import copy
n = int(eval(input()))
a = [int(x) for x in input().split()]
ans1=[(-1)**i for i in range(n)]

b=copy(a)
res_b=0
c=copy(a)
res_c=0
for i in range(n):
  if ans1[i]*sum(b[:i+1])>0:
    pass
  else:
    b[i]=ans1[i]-sum(b[:i])
    res_b+=abs(b[i]-a[i])
  if -1*ans1[i]*sum(c[:i+1])>0:
    pass
  else:
    c[i]=-1*ans1[i]-sum(c[:i])
    res_c+=abs(c[i]-a[i])
  
print((min(res_b,res_c)))

# Optimized solution
from copy import copy
n = int(eval(input()))
a = [int(x) for x in input().split()]
ans1=[(-1)**i for i in range(n)]

b=copy(a)
res_b=0
sb=0
c=copy(a)
res_c=0
sc=0
for i in range(n):
  sb+=a[i]
  if ans1[i]*sb>0:
    pass
  else:
    b[i]=ans1[i]-(sb-b[i])
    sb=sb-a[i]+b[i]
    res_b+=abs(b[i]-a[i])

  sc+=a[i]
  if -1*ans1[i]*sc>0:
    pass
  else:
    c[i]=-1*ans1[i]-(sc-c[i])
    sc=sc-a[i]+c[i]
    res_c+=abs(c[i]-a[i])
  
print((min(res_b,res_c)))
# Original solution
import sys
input = sys.stdin.readline

n = int(eval(input()))
a = [int(i) for i in input().split()]

# i番目までの和が正(i: 奇数)
res1 = 0
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 1:
        while cum <= 0:
            cum += 1
            res1 += 1
    else:
        while cum >= 0:
            cum -= 1
            res1 += 1

# i番目までの和が負(i: 奇数)
res2 = 0
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 0:
        while cum <= 0:
            cum += 1
            res2 += 1
    else:
        while cum >= 0:
            cum -= 1
            res2 += 1

print((min(res1,res2)))

# Optimized solution
import sys
input = sys.stdin.readline

n = int(eval(input()))
a = [int(i) for i in input().split()]

# i番目までの和が正(i: 奇数)
res1 = 0
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 1:
        if cum <= 0:
            res1 += (1 - cum)
            cum = 1
    else:
        if cum >= 0:
            res1 += (cum + 1)
            cum = -1

# i番目までの和が正(i: 偶数)
res2 = 0
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 0:
        if cum <= 0:
            res2 += (1 - cum)
            cum = 1
    else:
        if cum >= 0:
            res2 += (cum + 1)
            cum = -1

print((min(res1,res2)))
# Original solution
def sign(x):
    if x>0:
        return 1
    elif x<0:
        return -1
    else:
        return 0


n = int(eval(input()))
a = [int(i) for i in input().split()]
s = [sum(a[:i+1]) for i in range(n)]
sp = [s[i] for i in range(n)]
sm = [s[i] for i in range(n)]
P0=0
M0=0
if s[0]==0:
    P0+=1
    M0+=1
    for j in range(n):
        sp[j]+=1
        sm[j]+=1
elif s[0]>0:
    M0+=abs(s[0]+1)
    for j in range(n):
        sm[j]-=(abs(s[0])+1)
else:
    P0+=abs(s[0]+1)
    for j in range(n):
        sp[j]+=(abs(s[0])+1)
for i in range(1,n):
    if sm[i-1]*sm[i]>=0:
        M0+=abs(sm[i])+1
        h=sign(sm[i-1])*(-1)*(abs(sm[i])+1)
        for j in range(i,n):
            sm[j]+=h
    if sp[i-1]*sp[i]>=0:
        P0+=abs(sp[i])+1
        h=sign(sp[i-1])*(-1)*(abs(sp[i])+1)
        for j in range(i,n):
            sp[j]+=h
print((min([M0,P0])))


# Optimized solution
def sign(p):
    if p<0:
        return -1
    elif p>0:
        return 1
    else:
        return 0
N=int(eval(input()))
a=[int(i) for i in input().split()]
m=[0,0]
for sgn in [-1,1]:
    x=0
    S=0
    for i in range(N):
        S+=a[i]
        if sign(S)==sgn*(-1)**(i%2) or sign(S)==0:
            x+=abs(S)+1
            S=sgn*(-1)**((i+1)%2)
    m[(sgn+1)//2]=x
print((min(m)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

#      0  1  2  3  evn odd
# kevn +  -  +  -   +   -
# kodd -  +  -  +   -   +

a0=a[0]
if a0<0:
    kevn=1-a0
    sevn=1
elif a0==0:
    kevn=1
    sevn=1
elif a0>0:
    kevn=0
    sevn=a0

for i in range(1,n):
    ai=a[i]
    if i%2==0:
        if sevn+ai<0:
            kevn=kevn+1-(ai+sevn)
            sevn=1
        elif sevn+ai==0:
            kevn=kevn+1
            sevn=1
        elif sevn+ai>0:
            kevn=kevn
            sevn=sevn+ai
    elif i%2==1:
        if sevn+ai<0:
            kevn=kevn
            sevn=sevn+ai
        elif sevn+ai==0:
            kevn=kevn+1
            sevn=-1
        elif sevn+ai>0:
            kevn=kevn+1+(ai+sevn)
            sevn=-1
kevn1=kevn
            
a0=-a[0]
if a0<0:
    kevn=1-a0
    sevn=1
elif a0==0:
    kevn=1
    sevn=1
elif a0>0:
    kevn=0
    sevn=a0

for i in range(1,n):
    ai=-a[i]
    if i%2==0:
        if sevn+ai<0:
            kevn=kevn+1-(ai+sevn)
            sevn=1
        elif sevn+ai==0:
            kevn=kevn+1
            sevn=1
        elif sevn+ai>0:
            kevn=kevn
            sevn=sevn+ai
    elif i%2==1:
        if sevn+ai<0:
            kevn=kevn
            sevn=sevn+ai
        elif sevn+ai==0:
            kevn=kevn+1
            sevn=-1
        elif sevn+ai>0:
            kevn=kevn+1+(ai+sevn)
            sevn=-1
            
kevn=min(kevn,kevn1)

print(kevn)
            

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))

#      0  1  2  3  evn odd
# kevn +  -  +  -   +   -
# kodd -  +  -  +   -   +

def kf(a,flag,n):
    a0=a[0]*flag
    if a0<=0:
        kevn=1-a0
        sevn=1
    elif a0>0:
        kevn=0
        sevn=a0

    for i in range(1,n):
        ai=a[i]*flag
        if i%2==0:
            if sevn+ai<=0:
                kevn=kevn+1-(ai+sevn)
                sevn=1
            elif sevn+ai>0:
                kevn=kevn
                sevn=sevn+ai
        elif i%2==1:
            if sevn+ai<0:
                kevn=kevn
                sevn=sevn+ai
            elif sevn+ai>=0:
                kevn=kevn+1+(ai+sevn)
                sevn=-1
    return kevn

print((min(kf(a,1,n),kf(a,-1,n))))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

minA = 0
sumA = 0
# 奇数項を正としたときの操作回数minA 
for i in range(n):
  sumA += a[i]
  if i%2 == 0:        
    if sumA <= 0:
      minA += abs(sumA)+1
      sumA += abs(sumA)+1
  else:
    if sumA >= 0:
      minA += abs(sumA)+1
      sumA -= abs(sumA)+1
temp = 0
# 偶数項を正としたときの操作回数minB
minB = 0
sumB = 0
for i in range(n):
  sumB += a[i]
  if i%2 != 0:
    if sumB <= 0:
      minB += abs(sumB)+1
      sumB += abs(sumB)+1
  else:
    if sumB >= 0:
      minB += abs(sumB)+1
      sumB -= abs(sumB)+1
print((min(minA, minB)))      

# Optimized solution
def F(list_A, sign):
  total = 0
  cnt = 0
  for a in list_A:
    total += a
    if sign==True and total < 1:
      cnt += 1- total
      total = 1
    elif sign==False and total > -1:
      cnt += total + 1
      total = -1
    
    sign = not sign
  return cnt

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

ans = min(F(A, True), F(A, False))
print(ans)