cho.sh
Notes
Loading...

Maximum Subarray Sum

Time limit

1s

Memory limit

128 MB

Problem

You are given a sequence of n integers. Find the maximum possible sum obtainable by choosing one or more consecutive elements of the sequence.

Input

The first line contains an integer n (1 ≤ n ≤ 100,000).

The second line contains n integers separated by spaces. Each integer is between -1,000 and 1,000, inclusive.

Output

Print the maximum sum obtainable by choosing one or more consecutive elements.