Problem2194--ABC238B-Pizza

2194: ABC238B-Pizza

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Problem Statement

We have a circular pizza.
Takahashi will cut this pizza using a sequence AA of length NN, according to the following procedure.
  • First, make a cut from the center in the 1212 o'clock direction.
  • Next, do NN operations. The ii-th operation is as follows.
    • Rotate the pizza A_iAi degrees clockwise.
    • Then, make a cut from the center in the 1212 o'clock direction.
For example, if A=(90,180,45,195)A=(90,180,45,195), the procedure cuts the pizza as follows.

Find the center angle of the largest pizza after the procedure.

Constraints

  • All values in input are integers.
  • 1 \le N \le 3591N359
  • 1 \le A_i \le 3591Ai359
  • There will be no multiple cuts at the same position.

Input

Input is given from Standard Input in the following format:
NNA_1A1A_2A2\dotsA_NAN

Output

Print the answer as an integer.

Sample Input Copy

4
90 180 45 195

Sample Output Copy

120

Source/Category