Source Code

n = int(input())
tmp = input()
k = tmp.split(" ")

current = 0
min = int(k[0])
for c in k:
    current += int(c)
    if (min >= current):
        min = current
    
if (min <= 0):
    min = min * -1
    min = min + 1
    print(min)
else:
    print(0)
Copy
Zeina The Business Owner SilverCryptor
Python 3
49 ms
11.2 MB
Accepted