#K74737. Maximum Energy Points on a Circular Track

    ID: 34264 Type: Default 1000ms 256MiB

Maximum Energy Points on a Circular Track

Maximum Energy Points on a Circular Track

Nina is running on a circular track divided into several sections. Each section is assigned an energy point value. When Nina runs, she collects the energy points of each section she passes. Since the track is circular, she can run continuously in one direction and complete a full circle, collecting all the energy points along the way.

Your task is to help Nina determine the maximum total energy points she can collect, which is simply the sum of the energy points for all sections. In mathematical notation, if the energy points are given by \( a_1, a_2, \ldots, a_n \), then the answer is \( \sum_{i=1}^{n} a_i \).

inputFormat

The input consists of several datasets. Each dataset starts with an integer n representing the number of sections, followed by a line containing n space-separated integers representing the energy points on each section. The input is terminated by a line with a single zero (0), which should not be processed.

Input Format:

n
s1 s2 ... sn
n
s1 s2 ... sn
0

outputFormat

For each dataset, output a single line containing the maximum total energy points that can be collected.

Output Format:

result1
result2
...
## sample
5
3 2 1 4 5
4
1 3 6 2
0
15

12

</p>