#t90. 最大连续子列和问题
最大连续子列和问题
Maximum Continuous Subsequence Sum
Problem Description
Given a sequence of integers , a "continuous subsequence" is defined as , where . The "maximum continuous subsequence sum" is the largest among the sums of all such continuous subsequences. For example, given the sequence , the continuous subsequence has the maximum sum, which is .
Write a program to compute the maximum continuous subsequence sum of a given integer sequence.
Input Format
The first line gives a positive integer .
The second line gives the integers, separated by spaces.
Output Format
Output the maximum continuous subsequence sum on a single line (guaranteed to fit within the range of int).
If all integers in the sequence are negative, output .
Sample Input
6
-2 11 -4 13 -5 -2
Sample Output
20