Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

#第一項を正とするか負とするかで2パターン
#正
count1 = 0
if A[0] <= 0:
  sum1 = 1
  count1 = 1 - A[0]
else:
  sum1 = A[0]

for i in range(1, N):
  if i % 2 == 0:#和が正になるとき
    if sum1 + A[i] <= 0:
      count1 += 1 - (sum1 + A[i]) 
      sum1 = 1
    else:
      sum1 += A[i]
  if i % 2 == 1:
    if sum1 + A[i] >= 0:
      count1 += 1 + (sum1 + A[i]) 
      sum1 = -1
    else:
      sum1 += A[i]
  #print(count1,sum1)
#負
count2 = 0
if A[0] >= 0:
  sum2 = -1
  count2 = 1 + A[0]
else:
  sum2 = A[0]

for i in range(1, N):
  if i % 2 == 0:#和が負になるとき
    if sum2 + A[i] >= 0:
      count2 += 1 + (sum2 + A[i]) 
      sum2 = -1
    else:
      sum2 += A[i]
  if i % 2 == 1:
    if sum2 + A[i] <= 0:
      count2 += 1 - (sum2 + A[i]) 
      sum2 = 1
    else:
      sum2 += A[i]

print(min(count1, count2))
#print(count1, count2)

# Example run
# Input:
-114
-473
# Output:
0
def culc(a, plus):
    sum = 0
    ans = 0
    for i in range(len(a)):
        sum += a[i]
        if plus:
            if sum <= 0:
                ans += abs(sum) + 1
                sum = 1
        else:
            if sum >= 0:
                ans += abs(sum) + 1
                sum = -1
        plus = not(plus)
    return ans

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

plus = None
if a[0] >= 0:
    plus = True
else:
    plus = False

ans1 = culc(a, plus)
ans2 = culc(a, not(plus))

print(min(ans1, ans2))

# Example run
# Input:
505288784
57712056
# Output:
0
n = int(input())
a = list([int(i) for i in input().split()])
sum_a = []
count = 0

sum_a.append(a[0])
print(a)
for i in range(1,n):
    sum_a.append(sum_a[i-1] + a[i])

    if sum_a[i] == 0:
        if sum_a[i-1] < 0:
            sum_a[i] += 1
            count += 1
        else:
            sum_a[i] -= 1
            count += 1
    elif sum_a[i-1] * sum_a[i]>0:
        if sum_a[i] > 0:
            sum_a[i] = -1
            count += 1 + abs(sum_a[i-1]+a[i])
        else:
            sum_a[i] = 1
            count += 1 + abs(sum_a[i-1]+a[i])
print(sum_a)
print(count)

# Example run
# Input:
-450
139
# Output:
[139]
[139]
0
n = int(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)


# Example run
# Input:
-7038374
-6
# Output:
0
n = int(input())
a = list(map(int, input().split()))
L = [0 for _ in range(n)]
L[0] = a[0]
for i in range(1, n):
  L[i] = L[i-1] + a[i]
delay = 0
all_over = 0
if a[0] != 0:
  sign = (a[0] > 0) - (a[0] < 0)
  for i in range(1, n):
    L[i] += delay
    if L[i] <= 0 and sign == -1:
      delay += 1 - L[i]
      all_over += 1 - L[i]
      L[i] = 1
    elif L[i] >= 0 and sign == 1:
      delay -= L[i] + 1
      all_over += L[i] + 1
      L[i] = -1
    sign *= -1
  print(all_over)

# Example run
# Input:
1
8030667
# Output:
0
n = int(input())
A = list(map(int, input().split()))

def chk(A, first):
  sum = 0
  count = 0
  t = first
  for a in A:
    sum += a
    if t == True and sum < 1:
      count += 1-sum
      sum = 1
    elif t == False and sum > -1:
      count += sum + 1
      sum = -1
    t = not t
  return count
print(min(chk(A, True), chk(A, False)))

# Example run
# Input:
-1151131
-195933
# Output:
0
n = int(input())
lis = list(map(int,input().split()))
li = lis
cou = 0
co = 0
for i in range(n):
  if i % 2 == 0:
    if sum(li[:i+1]) <= 0:
      cou += (1-sum(li[:i+1]))
      li[i] += (1-sum(li[:i+1]))
  else:
    if sum(li[:i+1]) >= 0:
      cou += sum(li[:i+1])+1
      li[i] -= (sum(li[:i+1])+1)
for i in range(n):
  if i % 2 != 0:
    if sum(lis[:i+1]) <= 0:
      co += (1-sum(lis[:i+1]))
      lis[i] += (1-sum(lis[:i+1]))
  else:
    if sum(lis[:i+1]) >= 0:
      co += sum(lis[:i+1])+1
      lis[i] -= (sum(lis[:i+1])+1)
      
print(min(co,cou))
    

# Example run
# Input:
-1
-3439167
# Output:
0
n=int(input())
l=[int(i) for i in input().split()]
sm=l[0]
req=0 
pr=1 
if sm>0:
    pass 
else:
    req+=-sm+1 
    sm=1 
for i in range(1,n):
    if pr==1:
        n1=sm+l[i]
        if n1<0:
            sm+=l[i]
            pass 
        else: 
            sm+=l[i]
            req+=sm+1 
            sm=-1 
    else: 
        n1=sm+l[i]
        if n1>0:
            sm+=l[i]
            pass 
        else: 
            sm+=l[i]
            req+=(-sm+1) 
            sm=1 
    pr=1-pr  
req1=0 
pr=0
sm=l[0]
if sm<0:
    pass 
else:
    req1+=sm+1 
    sm=-1 
for i in range(1,n):
    if pr==1:
        n1=sm+l[i]
        if n1<0:
            sm+=l[i]
            pass 
        else: 
            sm+=l[i]
            req1+=sm+1 
            sm=-1 
    else: 
        n1=sm+l[i]
        if n1>0:
            sm+=l[i]
            pass 
        else: 
            sm+=l[i]
            req1+=(-sm+1) 
            sm=1 
    pr=1-pr  
print(min(req,req1))

# Example run
# Input:
-47187920
-8116
# Output:
0
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

# Example run
# Input:
U({C
1049999
# Output:
0
n = int(input())
a = list(map(int,input().split()))

#A1 ~ Aiまでの和 O(logN)
def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(idx,x):
    while idx <= n:
        BIT[idx] += x
        idx += (idx&(-idx))
    return


BIT = [0]*(n+1)
for i,e in enumerate(a):
   BIT_update(i+1,e)
ans1=0
for i in range(1,n+1):
    SUM=BIT_query(i)
    if i%2==1:
        if SUM<=0:
            ans1+=1-SUM
            BIT_update(i,1-SUM)
    else:
        if SUM>=0:
            ans1+=1+SUM
            BIT_update(i,-1-SUM)


BIT = [0]*(n+1)
for i,e in enumerate(a):
    BIT_update(i+1,e)
ans2=0
for i in range(1,n+1):
    SUM=BIT_query(i)
    if i%2==0:
        if SUM<=0:
            ans2+=1-SUM
            BIT_update(i,1-SUM)
    else:
        if SUM>=0:
            ans2+=1+SUM
            BIT_update(i,-1-SUM)

print(min(ans1,ans2))

# Example run
# Input:
-1
-3439167
# Output:
0
import math


"""
e.g. N=3 a=[-1 1 1]
 -1 2  1 :1
 -1 2 -2 :4

e.g. N=3 a=[0 0 -1]
 1  0 -1 :1
 1 -2 -1 :3
 1 -2  2 :6

 -1 0 -1 :1
 -1 2 -1 :3
 -1 2 -2 :4

e.g. N=3 a=[0 0 1]
 1  0 1 :1
 1 -2 1 :3
 1 -2 2 :4

 -1 0  1 :1
 -1 2  1 :3
 -1 2 -2 :6

e.g. N=4 a=[0 0 0 -1]
 1  0 0 -1 :1
 1 -2 0 -1 :3
 1 -2 2 -1 :5
 1 -2 2 -2 :6

 -1 0  0 -1 :1
 -1 2  0 -1 :3
 -1 2 -2 -1 :5
 -1 2 -2  2 :8

e.g. N=4 a=[0 0 0 1]
 1  0 0  1 :1
 1 -2 0  1 :3
 1 -2 2  1 :5
 1 -2 2 -2 :8

 -1 0  0 1 :1
 -1 2  0 1 :3
 -1 2 -2 1 :5
 -1 2 -2 2 :6
"""


def main2():
    """
    累積和は、偶奇,奇偶のどちらかの数列になるので２種類試す
    """
    n = int(input())
    A = list(map(int, input().split()))

    ans = float("inf")
    for sign in (1, -1):
        s, n_op = 0, 0
        for a in A:
            s += a
            # if sign == 1 and s <= 0:
            # elif sign == -1 and s >= 0:
            if s * sign <= 0:
                # 調整
                n_op += abs(s) + 1
                s = sign

            # 偶奇の入れ替え
            sign *= -1

        ans = min(ans, n_op)

    print(ans)


def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0

    # 最初から0続きのとき、操作が少なくなるように同じ符号にする
    def sign(x):
        if x == 0:
            return 0
        return int(math.copysign(1, x))

    if a[0] == 0:
        for i in range(1, n):
            if a[i] != 0:
                sign_a = sign(a[i])
                if i % 2 == 0:
                    # odd: 1-indexed
                    a[0] = sign_a
                else:
                    a[0] = -sign_a

                ans += 1
                break
    s = a[0]

    for i in range(1, n):
        s1 = s + a[i]
        sign_s = sign(s)
        sign_s1 = sign(s1)

        if s1 == 0 or sign_s == sign_s1:
            # 逆方向に変更
            # new_s1 = -sign_s = s+a[i] + diff
            diff = -(sign_s + s + a[i])
            a[i] += diff
            ans += abs(diff)

        s += a[i]

        #print(i, a, sep="\t")
    print(ans)

if __name__ == '__main__':
    main2()


# Example run
# Input:
-84
-199220713
# Output:
0
N = int(input())
A = list(map(int, input().split()))
B = [A[0]]
for i in range(1,N):
  A[i] += A[i-1]

th = min(0, A[0]-1)
ans_pos = abs(th) #正スタート
for i in range(1,N):
  if i % 2 == 1: #負にしたい
    ans_pos += abs(th - max(th, A[i]+1))
    th = max(th, A[i]+1)
  else: #正にしたい
    ans_pos += abs(th - min(th, A[i]-1))
    th = min(th, A[i]-1)
  #print(ans_pos, th, i)

th = max(0, A[0]+1)
ans_neg = abs(th) #負スタート
for i in range(1,N):
  if i % 2 == 1: #正にしたい
    ans_neg += abs(th - min(th, A[i]-1))
    th = min(th, A[i]-1)
  else: #負にしたい
    ans_neg += abs(th - max(th, A[i]+1))
    th = max(th, A[i]+1)
  #print(ans_neg, th, i)

print(min(ans_pos, ans_neg))

# Example run
# Input:
-224231
-640183291
# Output:
0
n = int(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:
        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(count)

# Example run
# Input:
6697
-2
# Output:
0
n = int(input())
l = list(map(int,input().split()))

if l[0] <= 0:
    x = 1
    ans1 = 1-l[0]
else:
    x = l[0]
    ans1 = 0
def check(l,x):
    ans=0
    for i in range(1,n):
        if x < 0:
            if x + l[i] <= 0:
                ans += 1-(x+l[i])
                x = 1
            else:
                x = x + l[i]
        else:
            if x + l[i] >= 0:
                ans += x + l[i] + 1
                x = -1
            else:
                x = x + l[i]
    return ans
ans1 += check(l,x)
if l[0] >= 0:
    x = -1
    ans2 = l[0]+1
else:
    ans2 = 0
    x = l[0]
ans2 += check(l,x)
print(min(ans1,ans2))


# Example run
# Input:
-877447
8312590
# Output:
0
def sequence(N: int, A: list) -> int:
    def count_op(s: int) -> int:
        op = 0

        if s * A[0] > 0:
            s = A[0]
        else:
            s = s / abs(s)
            op = abs(1 - s)

        for a in A[1:]:
            if s < 0:
                if s + a > 0:
                    # OK
                    s = s + a
                    continue
                else:
                    op += 1 - (s + a)
                    s = 1
            else:  # s > 0
                if s + a < 0:
                    # OK
                    s = s + a
                    continue
                else:
                    op += (s + a) - (-1)
                    s = -1
        return op

    return min(count_op(1), count_op(-1))


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = sequence(N, A)
    print(ans)


# Example run
# Input:
386945
3485
# Output:
0
n = int(input().strip())
A = list(map(int, input().strip().split(" ")))

def solver(_sign):
    s = A[0]
    count = 0

    if _sign:
        if s <= 0: # head is positive
            count += abs(s) + 1
            s = 1
    else:
        if s >= 0: # head is negative
            count += abs(s) + 1
            s = -1

    for a in A[1:]:
        prev = s
        sign = prev > 0
        s += a
        if s == 0:
            count += 1
            if sign: # previous is positive
                s = -1
            else: # prev is negative
                s = 1
        elif sign == (s > 0): # previous and current have the same sign
            count += abs(s)+1
            if s > 0:
                s = -1
            else:
                s = 1
        else:
            pass
    return count

print(min(solver(True), solver(False)))

# Example run
# Input:
-58799
-1
# Output:
0
n = int(input())
a = [int(i) for i in input().split()]
cur = 0
ans1, ans2 = 0,0
for i, x in enumerate(a):
    cur += x
    if i%2 == 0:
        if cur >= 1:
            continue
        else:
            ans1 += abs(1-x)
    else:
        if cur <= -1:
            continue
        else:
            ans1 += abs(-1-x)
for i, x in enumerate(a):
    cur += x
    if i%2 != 0:
        if cur >= 1:
            continue
        else:
            ans2 += abs(1-x)
    else:
        if cur <= -1:
            continue
        else:
            ans2 += abs(-1-x)
print(min(ans1, ans2))

# Example run
# Input:
28016
-48
# Output:
0
N = int(input())
A = [int(x) for x in input().split()]

def f(sgn):
    cum = 0
    cnt_operation = 0
    for a in A:
        sgn *= -1
        cum += a
        if cum * sgn > 0:
            continue
        else:
            cnt_operation += abs(cum) + 1
            cum = sgn
    return cnt_operation
print(min(f(-1), f(1)))



# Example run
# Input:
-74461
-1151131
# Output:
0
n = int(input())
a = list(map(int,input().split()))

point = 0
point2 = 0

now = 0
now2 = 0

for i,j in enumerate(a):
    now += j
    now2 += j
    if i%2 == 0:
        if now <= 0:
            point += 1-now
            now = 1
        if now2 >= 0:
            point2 += 1+now2
            now2 = -1
    else:
        if now2 <= 0:
            point2 += 1-now2
            now2 = 1
        if now >= 0:
            point += 1+now
            now = -1

print(min(point,point2))

# Example run
# Input:
-27
230
# Output:
0
# vim: fileencoding=utf-8


def calc(a, flg):
    ans = 0
    cursol = a[0]
    if flg == 1:
        if cursol <= 0:
            cursol = 1
            ans = abs(cursol) + 1
    elif flg == -1:
        if cursol >= 0:
            cursol = -1
            ans = abs(cursol) + 1
    for i in a[1:]:
        t = cursol + i
        if cursol > 0:
            if t >= 0:
                ans += t + 1
                cursol = -1
            else:
                cursol = t
        elif cursol < 0:
            if t <= 0:
                ans += abs(t) + 1
                cursol = 1
            else:
                cursol = t
    return ans


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = min(calc(a, 1), calc(a, -1))
    print(ans)


if __name__ == "__main__":
    main()


# Example run
# Input:
1547
-15
# Output:
0
n = int(input())
a = [int(_) for _ in input().split()]
even_p = 0
even_n = 0
odd_p = 0
odd_n = 0
for i in range(n):
    if i % 2 == 0:
        if a[i] > 0:
            odd_p += 1
        elif a[i] < 0:
            odd_n += 1
    else:
        if a[i] > 0:
            even_p += 1
        elif a[i] < 0:
            even_n += 1
cnt = 0
if odd_p - odd_n > even_p - even_n:
    if a[0] > 0:
        sum_i = a[0]
    else:
        cnt += abs(a[0]-1)
        sum_i = 1
else:
    if a[0] < 0:
        sum_i = a[0]
    else:
        cnt += abs(a[0] + 1)
        sum_i = -1
for i in range(1, n):
    if sum_i > 0:
        if sum_i + a[i] < 0:
            sum_i += a[i]
        else:
            cnt += abs(a[i]+sum_i+1)
            sum_i = -1
    elif sum_i < 0:
        if sum_i + a[i] > 0:
            sum_i += a[i]
        else:
            cnt += abs(a[i]+sum_i-1)
            sum_i = 1
print(cnt)

# Example run
# Input:
-126905272
28016
# Output:
28017
N = int(input())
A = [int(x) for x in input().split()]
ans_plusstart = 0
sum_plusstart = 0
ans_minusstart = 0
sum_minusstart = 0
if A[0] < 0:
    ans_plusstart += 1 - A[0]
    sum_minusstart = A[0]
    sum_plusstart = 1
else:
    ans_minusstart += 1 + A[0]
    sum_minusstart = -1
    sum_plusstart = max(1, A[0])
    if A[0] == 0:
        ans_plusstart = 1
for i in range(1, N):
    #print(sum_plusstart, ans_plusstart, sum_minusstart, ans_minusstart)
    if i % 2 == 0:  # スタートと同じ記号にしたい
        if A[i] + sum_plusstart > 0:
            sum_plusstart = A[i] + sum_plusstart
        if A[i] + sum_plusstart <= 0:
            ans_plusstart += 1-(A[i] + sum_plusstart)
            sum_plusstart = 1

        if A[i] + sum_minusstart < 0:
            sum_minusstart = A[i] + sum_minusstart
        if A[i] + sum_minusstart >= 0:
            ans_minusstart += 1 + A[i] + sum_minusstart
            sum_minusstart = -1

    else:  # スタートと違う記号にしたい
        if A[i] + sum_plusstart < 0:
            sum_plusstart = A[i] + sum_plusstart
        if A[i] + sum_plusstart >= 0:
            ans_plusstart += 1+A[i] + sum_plusstart
            sum_plusstart = -1

        if A[i] + sum_minusstart > 0:
            sum_minusstart = A[i] + sum_minusstart
        if A[i] + sum_minusstart <= 0:
            ans_minusstart += 1 - (A[i] + sum_minusstart)
            sum_minusstart = -1
print(min(ans_minusstart, ans_plusstart))


# Example run
# Input:
-86
0
# Output:
1
N = int(input())
A = tuple(map(int, input().split(" ")))

m = 0
c = 0
for i in range(N):
	if i%2 == 0:
		m += A[i]
		while m <= 0:
			m += 1
			c += 1
	else:
		m += A[i]
		while m >= 0:
			m -= 1
			c += 1

o = 0
d = 0
for i in range(N):
	if i%2 == 1:
		o += A[i]
		while o <= 0:
			o += 1
			d += 1
	else:
		o += A[i]
		while o >= 0:
			o -= 1
			d += 1

print(min(c, d))

# Example run
# Input:
-93026
90
# Output:
0
N = int(input())
A = [int(x) for x in input().split()]
c = [0, 0]

for f in [0, 1]:
  sumA = 0
  for i, a in enumerate(A):
    sumA += a
    if i % 2 == f:
      if sumA < 1:
        d = 1 - sumA
        c[f] += d
        sumA += d
    else:
      if sumA > -1:
        d = 1 + sumA
        c[f] += d
        sumA -= d
      
print(min(c))

# Example run
# Input:
-274078593
-28418
# Output:
0
n = int(input())
arr = [int(x) for x in input().split()]

def exec(sign):
    a = [x for x in arr]
    res = 0

    if a[0] == 0:
        a[0] -= sign
        res += 1

    x = 0
    for i in range(n-1):
        x += a[i]
        tmp = sign - (x + a[i+1])
        if sign < 0:
            tmp = min(tmp, 0)
        else:
            tmp = max(tmp, 0)
        res += abs(tmp)
        a[i+1] += tmp
        sign *= (-1)
    return res

print(min(exec(1), exec(-1)))


# Example run
# Input:
-37
1
# Output:
0
n = int(input())
A = list(map(int, input().split()))

ans = 1e16
for s in (1, -1):
    res, acc = 0, 0
    for a in A:
        acc += a
        if acc * s <= 0:
            res += abs(acc-s)
            acc = s
        s *= -1
    ans = min(ans, res)

print(ans)


# Example run
# Input:
0
456
# Output:
0
def c(ints):
    
    for i in range(len(ints)):
        if ints[i] != 0:
            sig = 1 if ints[i] > 0 else -1
            sig_ = -sig
            total = ints[i]
            total_ = -sig
            mov = i
            mov_ = abs(total) + 1
            if i > 0:
                mov += 1 + i - 1
                mov_ += 2 + i - 1
            j = i
            break
        if i == len(ints) - 1:
            return i * 2 + 1
    
    for i_ in ints[j+1:]:
        tmp = total + i_
        tmp_ = total_ + i_
        if tmp == 0:
            mov +=1
            tmp = -sig
        elif sig * tmp > 0:
            mov += abs(tmp) + 1
            tmp = -sig
            
        if tmp_ == 0:
            mov_ +=1
            tmp_ = -sig_
        elif sig_ * tmp_ > 0:
            mov_ += abs(tmp_) + 1
            tmp_ = -sig_
            
        sig *= -1
        total = tmp
        sig_ *= -1
        total_ = tmp_
    
    return min(mov, mov_)

_ = input()
inp = input()
inp = inp.split(' ')
inp = [int(i_) for i_ in inp]
print(c(inp))

# Example run
# Input:
S43brt#
104248
# Output:
0
def c(ints):
    
    for i in range(len(ints)):
        if ints[i] != 0:
            sig = 1 if ints[i] > 0 else -1
            sig_ = -sig
            total = ints[i]
            total_ = -sig
            mov = i
            mov_ = abs(total) + 1
            if i > 0:
                mov += 1
                mov_ += 1
            j = i
            break
        if i == len(ints) - 1:
            return i + 1
    
    for i_ in ints[j+1:]:
        tmp = total + i_
        tmp_ = total_ + i_
        if tmp == 0:
            mov +=1
            tmp = -sig
        elif sig * tmp > 0:
            mov += abs(tmp) + 1
            tmp = -sig
            
        if tmp_ == 0:
            mov_ +=1
            tmp_ = -sig_
        elif sig_ * tmp_ > 0:
            mov_ += abs(tmp_) + 1
            tmp_ = -sig_
            
        sig *= -1
        total = tmp
        sig_ *= -1
        total_ = tmp_
    return min(mov, mov_)
 
_ = input()
inp = input()
inp = inp.split(' ')
inp = [int(i_) for i_ in inp]
print(c(inp))

# Example run
# Input:
!`^ct
14868324
# Output:
0
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a[i])

ct1=0
if a[0]<=0:
  ct1+=1-a[0]
  a[0]=1
x=a[0]
for i in range(1,n):
  y=x+a[i]
  if i%2==1:
    if y>=0:
      ct1+=y+1
      a[i]=-x-1
  else:
    if y<=0:
      ct1+=1-y
      a[i]=-x+1
  x+=a[i]

ct2=0
if b[0]>=0:
  ct2+=b[0]+1
  b[0]=-1
x=b[0]
for i in range(1,n):
  y=x+b[i]
  if i%2==0:
    if y>=0:
      ct2+=y+1
      b[i]=-x-1
  else:
    if y<=0:
      ct2+=1-y
      b[i]=-x+1
  x+=b[i]

print(min(ct1,ct2))

# Example run
# Input:
1
-10081
# Output:
0
import sys
# -*- coding: utf-8 -*-
# 整数の入力
n=int(input())
a=list(map(int, input().split()))
b=a[:]
c=a[:]
# 無変更チェック
if a[0]!=0:
  S=int(a[0])
  for i in range(1,n):
    if S<0 and S+a[i]<=0:
      break
    elif S>0 and S+a[i]>=0:
      break
    S+=a[i]
    if i==n-1:
      print(0)
      sys.exit()
# a[0]を1に変えた場合の計算
counter_2=abs(b[0]-1)
b[0]=1
S=b[0]
for i in range(1,n):
  if S<0 and S+b[i]<=0:
    counter_2+=-S-b[i]+1
    b[i]=-S+1
  elif S>0 and S+b[i]>=0:
    counter_2+=S+b[i]+1
    b[i]=-S-1
  S+=b[i]
# a[0]を-1に変えた場合の計算
counter_3=abs(c[0]+1)
c[0]=-1
S=c[0]
for i in range(1,n):
  if S<0 and S+c[i]<=0:
    counter_3+=-S-c[i]+1
    c[i]=-S+1
  elif S>0 and S+c[i]>=0:
    counter_3+=S+c[i]+1
    c[i]=-S-1
  S+=c[i]
print(min(counter_2,counter_3))

# Example run
# Input:
-7487220
-1005
# Output:
1004
n = input()
a = list(map(int, input().split()))


def chk(a, positive):
    ans = tmp = 0
    for x in a:
        tmp += x
        if positive and tmp < 1:
            ans += 1-tmp
            tmp = 1
        elif not positive and tmp > -1:
            ans += abs(-1-tmp)
            tmp = -1

        positive = not positive
    return ans

print(min((chk(a, True), chk(a, False))))

# Example run
# Input:
K<"=U6q
18
# Output:
0
n = int(input())
a = list(map(int,input().split()))
sun = 0
ans1 = 0
for i in range(n):
  if i == 0:
    SUN = 1
  else:
    SUN = sun
  now = a[i]
  if SUN * (sun+now) >= 0:
    ans1 += abs(sun+now) + 1
    if sun > 0:
      sun = -1
    else:
      sun = 1
  else:
    sun += now
sun = 0
ans2 = 0
for i in range(n):
  now = a[i]
  if i == 0:
    SUN = -1
  else:
    SUN = sun
  if SUN * (sun+now) >= 0:
    ans2 += abs(sun+now) + 1
    if sun > 0:
      sun = -1
    else:
      sun = 1
  else:
    sun += now
#print(ans1,ans2)
print(min(ans1,ans2))

# Example run
# Input:
-19797306
311070
# Output:
0
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

# Example run
# Input:
:q|Hq
141725276
# Output:
0