Softville Initiation Program

Find the smallest program length that each given day count can produce under the rule of writing one more line each day.

Medium7Number theoryMathNo attempts yetTime limit1sMemory limit256 MB

Problem

In the village of Softville, software is written one way. On the first day a programmer writes at least one line of code, and on every day after that the programmer writes exactly one line more than on the day before.

Once a citizen of Softville turns ten, the citizen has to pass an initiation: writing one very complicated program from scratch. The code of that program is the same for everyone and has exactly NN lines. The number of days needed to finish it can differ from citizen to citizen, but the rule always holds: every day a programmer writes one line more than the day before.

You are given how many days each citizen spent writing the initiation program. Find the smallest possible value of NN. The program is not empty, so NN is at least 1.

Input

The first line contains the number of citizens mm (0m10000 \le m \le 1000). The second line contains mm integers separated by spaces, the number of days each citizen spent writing the initiation program. Each of those numbers is positive and smaller than 2632^{63}. When m=0m = 0, the second line is empty.

Output

Print the smallest possible value of NN on one line. If no value of NN agrees with all of the given day counts, print 0. When an answer exists, it is smaller than 2632^{63}. When m=0m = 0, print 1.