~/algor $ cat problems/massiv-eng-katta-qism-yigindi
Maximum sum subarray
Medium
1000 ms
128 MB
59%
A positive integer $n$ and an array of $n$ integers are given. Find the largest sum among the non-empty contiguous subarrays of the array.
Input
The first line contains a positive integer $n$. The second line contains $n$ integers separated by spaces.
Output
One integer — the largest subarray sum.
Note
$1 \le n \le 2 * 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
6 -2 1 -3 4 -1 2
Output #1
5
Input #2
3 -5 -1 -8
Output #2
-1