105023 - 最大子序列和

给一串整数a[1],…,a[n],求出它的最大的子序列和,即找出1\le i\le j\le n,使得a[i]+a[i+1]+…+a[j]最大。

Input

输入第一行为一个整数n,表示有n(n\le35 000)个整数,第二行为n个整数。

Output

输出共一行,即最大子序列和。

Examples

Input

5
1 2 5 -10 7

Output

8
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题