LearnPy Hub
← Arena
IntermediateRating 1400

Best Sum Around a Circle

The numbers sit in a circle (the last is next to the first). Print the largest sum of a non-empty block of neighbouring numbers. Each number may be used at most once.

Input

n, then n integers.

Output

One integer.

Sample 1

Input
4
1 -2 3 -2
Output
3

Sample 2

Input
3
5 -3 5
Output
10
solution.py
Output appears here
Best Sum Around a Circle · Python Arena problem · LearnPy Hub