9 -2 1 -3 4 -1 2 1 -5 4
For this input, the required output is 6.
6
5 -5 -2 -8 -1 -3
For this input, the required output is -1.
-1
5 1 2 3 4 5
For this input, the required output is 15.
15
Given an array of nnn integers, find the maximum sum of any contiguous subarray.
A contiguous subarray is a sequence of consecutive elements from the array. The subarray must contain at least one element.
max_sum\text{max\_sum}max_sum