Buggy python submission (verdict: Time Limit Exceeded):
def osilate(seq):
    flag = 1
    acc = 0
    ans = 0
    #while loop O(n)
    while len(seq) > 0:
        a = seq[0]
        acc += a

        if flag > 0:
            if acc <= 0:
                ans += 1-acc
                acc = 1
        if flag < 0:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        #print(seq, acc, ans)
        seq.pop(0)
        flag = flag * (-1)
    return ans

n = int(input()) #(1)
seq = [int(i) for i in input().split()] #O(N)

seq_rev = [-i for i in seq]  # O(N)
print(min(osilate(seq),osilate(seq_rev))) #O(2N)


Fixed submission:
def osilate(seq):
    flag = 1
    acc = 0
    ans = 0
    #while loop O(n)
    for i in range(len(seq)):
        a = seq[i]
        acc += a
        flag = i%2

        if flag == 0:
            if acc <= 0:
                ans += 1-acc
                acc = 1
        if flag == 1:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        #print(seq, acc, acc)
        flag = flag * (-1)
    return ans

n = int(input()) #(1)
seq = [int(i) for i in input().split()] #O(N)

seq_rev = [-i for i in seq]  # O(N)
print(min(osilate(seq),osilate(seq_rev))) #O(2N)

Buggy python submission (verdict: Time Limit Exceeded):
def osilate(seq):
    flag = 1
    acc = 0
    ans = 0
    while len(seq) > 0:

        a = seq[0]
        acc += a

        if flag > 0:
            if acc <= 0:
                ans += 1-acc
                acc = 1
        if flag < 0:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        #print(seq, acc, ans)
        seq.pop(0)
        flag = flag * (-1)
    return ans

n = int(input())
seq = [int(i) for i in input().split()]
acc = []
tmp = 0

seq_rev = [-i for i in seq]
print(min(osilate(seq),osilate(seq_rev)))



Fixed submission:
def osilate(seq):
    flag = 1
    acc = 0
    ans = 0
    #while loop O(n)
    for i in range(len(seq)):
        a = seq[i]
        acc += a
        flag = i%2

        if flag == 0:
            if acc <= 0:
                ans += 1-acc
                acc = 1
        if flag == 1:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        #print(seq, acc, acc)
        flag = flag * (-1)
    return ans

n = int(input()) #(1)
seq = [int(i) for i in input().split()] #O(N)

seq_rev = [-i for i in seq]  # O(N)
print(min(osilate(seq),osilate(seq_rev))) #O(2N)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
def osilate(acc):
    acc = np.array(acc)
    flag = 1
    ans = 0
    while len(acc) > 0:
        #print(acc)
        a = acc[0]
        if flag > 0:
            if a <= 0:
                ans += 1-a
                acc = acc + (1-a)
        if flag < 0:
            if a >= 0:
                ans += 1+a
                acc = acc - (1+a)
        acc = acc[1:]
        flag = flag * (-1)
    return ans

n = int(input())
seq = [int(i) for i in input().split()]
acc = []
tmp = 0
for i in seq:
    tmp += i
    acc.append(tmp)
acc_rev = [-i for i in acc]

print(min(osilate(acc),osilate(acc_rev)))


Fixed submission:
def osilate(seq):
    flag = 1
    acc = 0
    ans = 0
    #while loop O(n)
    for i in range(len(seq)):
        a = seq[i]
        acc += a
        flag = i%2

        if flag == 0:
            if acc <= 0:
                ans += 1-acc
                acc = 1
        if flag == 1:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        #print(seq, acc, acc)
        flag = flag * (-1)
    return ans

n = int(input()) #(1)
seq = [int(i) for i in input().split()] #O(N)

seq_rev = [-i for i in seq]  # O(N)
print(min(osilate(seq),osilate(seq_rev))) #O(2N)