4190: 希希爱统计

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:13 Solved:4

Description

希希是一位爱学习爱计算的好同学。


现在老师给定 lns="http://www.w3.org/1998/Math/MathML"> 个整数 lns="http://www.w3.org/1998/Math/MathML">1,2,,,这 lns="http://www.w3.org/1998/Math/MathML"> 个整数首尾相连构成一个圆环,让希希从圆环中取出一段连续的数字(至少取 lns="http://www.w3.org/1998/Math/MathML">1 个),使得该段连续数字之和最大。

请输出最大的数字和。

样例 lns="http://www.w3.org/1998/Math/MathML">1 解释

选择区间 lns="http://www.w3.org/1998/Math/MathML">7lns="http://www.w3.org/1998/Math/MathML">3lns="http://www.w3.org/1998/Math/MathML">11 这几个连续的数,求和为 lns="http://www.w3.org/1998/Math/MathML">15

样例 lns="http://www.w3.org/1998/Math/MathML">2 解释

由于首尾相连构成圆环,因此从圆环上选择如下几个连续的数 lns="http://www.w3.org/1998/Math/MathML">20lns="http://www.w3.org/1998/Math/MathML">17lns="http://www.w3.org/1998/Math/MathML">1lns="http://www.w3.org/1998/Math/MathML">16lns="http://www.w3.org/1998/Math/MathML">13lns="http://www.w3.org/1998/Math/MathML">15,求和为 lns="http://www.w3.org/1998/Math/MathML">80

数据范围

对于 lns="http://www.w3.org/1998/Math/MathML">40% 的数据,lns="http://www.w3.org/1998/Math/MathML">11000

对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1105lns="http://www.w3.org/1998/Math/MathML">104104


Input

第 lns="http://www.w3.org/1998/Math/MathML">1 行输入整数 lns="http://www.w3.org/1998/Math/MathML">

第 lns="http://www.w3.org/1998/Math/MathML">2 行输入 lns="http://www.w3.org/1998/Math/MathML"> 个整数,数字之间用空格隔开。

Output

输出从圆环中取出连续数字的最大和。

Sample Input Copy

5
-11 7 -3 11 -17

Sample Output Copy

15

HINT

有坑,不要抄网上答案。


样例 lns="http://www.w3.org/1998/Math/MathML">1 解释

选择区间 lns="http://www.w3.org/1998/Math/MathML">7lns="http://www.w3.org/1998/Math/MathML">3lns="http://www.w3.org/1998/Math/MathML">11 这几个连续的数,求和为 lns="http://www.w3.org/1998/Math/MathML">15

样例 lns="http://www.w3.org/1998/Math/MathML">2 解释

由于首尾相连构成圆环,因此从圆环上选择如下几个连续的数 lns="http://www.w3.org/1998/Math/MathML">20lns="http://www.w3.org/1998/Math/MathML">17lns="http://www.w3.org/1998/Math/MathML">1lns="http://www.w3.org/1998/Math/MathML">16lns="http://www.w3.org/1998/Math/MathML">13lns="http://www.w3.org/1998/Math/MathML">15,求和为 lns="http://www.w3.org/1998/Math/MathML">80

数据范围

对于 lns="http://www.w3.org/1998/Math/MathML">40% 的数据,lns="http://www.w3.org/1998/Math/MathML">11000

对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1105lns="http://www.w3.org/1998/Math/MathML">104104