Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
ap = np.array(a)
an = np.array(a)
#+-+-...
if ap[0] <= 0:
    ap[0] = 1
for i in range(1, n):
    if sum(ap[:i+1]) <= 0 and i%2 == 0:
        ap[i] = 1 - sum(ap[:i]) 
    if sum(ap[:i+1]) >= 0 and i%2 == 1:
        ap[i] = -1 - sum(ap[:i])

#-+-+...
if an[0] >= 0:
    an[0] = -1
for i in range(1, n):
    if sum(an[:i+1]) <= 0 and i%2 == 1:
        an[i] = 1 - sum(an[:i]) 
    if sum(an[:i+1]) >= 0 and i%2 == 0:
        an[i] = -1 - sum(an[:i])
        
print(min(sum(abs(np.array(a) - ap)), sum(abs(np.array(a) - an))))

Fixed submission:
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)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
b = a.copy()

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

print(sum(abs(b-a)))

Fixed submission:
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)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
dummyn = int(input())
a = list(map(int, input().split()))
b_np = np.array([sum(a[:i+1]) for i in range(len(a))])

ans = 0
for i in range(len(b_np)-1):
    if b_np[i] * b_np[i+1] >= 0 and b_np[i] <= 0 and b_np[i] <= b_np[i+1]:
        ans += (1 - b_np[i+1])
        b_np[i+1:] += (1 - b_np[i+1])
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] < 0 and b_np[i] > b_np[i+1]:
        ans +=  (1 - b_np[i])
        b_np[i:] += (1 - b_np[i])
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] >= 0 and b_np[i] >= b_np[i+1]:
        ans += (b_np[i+1] + 1)
        b_np[i+1:] -= (b_np[i+1] + 1)
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] > 0 and b_np[i] < b_np[i+1]:
        ans += (b_np[i] + 1)
        b_np[i:] -= (b_np[i] + 1)

print(ans)

Fixed submission:
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)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
dummyn = int(input())
a = list(map(int, input().split()))

b = []
for i in range(len(a)):
    b.append(sum(a[:i+1]))

b_np = np.array(b)

ans = 0
for i in range(len(b_np)-1):
    if b_np[i] * b_np[i+1] >= 0 and b_np[i] <= 0 and b_np[i] <= b_np[i+1]:
        ans += (1 - b_np[i+1])
        b_np[i+1:] += (1 - b_np[i+1])
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] < 0 and b_np[i] > b_np[i+1]:
        ans +=  (1 - b_np[i])
        b_np[i:] += (1 - b_np[i])
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] >= 0 and b_np[i] >= b_np[i+1]:
        ans += (b_np[i+1] + 1)
        b_np[i+1:] -= (b_np[i+1] + 1)
    elif b_np[i] * b_np[i+1] >= 0 and b_np[i] > 0 and b_np[i] < b_np[i+1]:
        ans += (b_np[i] + 1)
        b_np[i:] -= (b_np[i] + 1)

print(ans)

Fixed submission:
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)))