Problem: p03739
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
num_list = list(map(int, input().split()))
count = 0
sum_ = num_list[0]
if sum_ > 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                sum_ += abs(sum_) + 1
                count += abs(sum_) + 1
        else:
            if sum_ >= 0:
                sum_ -= abs(sum_) + 1
                count += abs(sum_) + 1
    print(count)                
elif sum_ < 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                sum_ += abs(sum_) + 1
                count += abs(sum_) + 1
        else:
            if sum_ >= 0:
                sum_ += -abs(sum_) - 1
                count += abs(sum_) + 1 
    print(count)                
else:
    sum_ = 1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                sum_ += abs(sum_) + 1
                count += abs(sum_) + 1
        else:
            if sum_ >= 0:
                sum_ -= -abs(sum_) - 1
                count += abs(sum_) + 1
    count1 = count        
    sum_ = -1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                sum_ += abs(sum_) + 1
                count += abs(sum_) + 1
        else:
            if sum_ >= 0:
                sum_ += abs(sum_) + 1
                count += abs(sum_) + 1 
    count2 = count           
    print(min(count1, count2))

Failing test case input:
6
-1 4 1 2 -5 0

Expected output:
10


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
num_list = list(map(int, input().split()))
count = 0
sum_ = num_list[0]
if sum_ > 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count
    
    count = 0
    sum_ = -1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + num_list[0] + 1
    
    print(min(count1, count2))
elif sum_ < 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count
    
    count = 0
    sum_ = 1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + abs(num_list[0]) + 1
    
    print(min(count1, count2))
    
else:
    sum_ = -1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count + 1
    
    count = 0
    sum_ = 1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + 1    

    print(min(count1, count2))