LearnPy Hub
← Arena
IntermediateRating 1400

Maximum Subarray Sum

Find the largest possible sum of a non-empty contiguous subarray.

Input

First line n, second line n integers.

Output

The maximum sum.

Sample 1

Input
9
-2 1 -3 4 -1 2 1 -5 4
Output
6

Sample 2

Input
3
-3 -1 -2
Output
-1
solution.py
Output appears here
Maximum Subarray Sum · Python Arena problem · LearnPy Hub