"""
Exercise 1: Minimum Value to Get Positive Step by Step Sum (LeetCode 1413)

Starting from startValue, you add nums one by one. Return the minimum
positive startValue such that the running total is never less than 1.

Hint: track the minimum prefix sum.

  min_start_value([-3, 2, -3, 4, 2]) -> 5
  min_start_value([1, 2])            -> 1
"""

def min_start_value(nums):
    # TODO
    pass


# --- self-check: do not modify below this line ---
cases = [([-3, 2, -3, 4, 2], 5), ([1, 2], 1), ([1, -2, -3], 5), ([-5], 6)]
ok = True
for nums, want in cases:
    got = min_start_value(nums)
    print(nums, "->", got, "expected", want)
    ok = ok and got == want
print("PASS" if ok else "FAIL")
