arr = [10, -4, 3, 1, 5, 6, -35, 12, 21, -1]

current_sum = arr[0]
max_sum = arr[0]

for i in range(1, len(arr)):
    current_sum = max(arr[i], current_sum + arr[i])
    max_sum = max(max_sum, current_sum)

print(max_sum)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: