Sequences

No attempts yetTime limit1sMemory limit256 MB

Problem

Let x1<x2<<xnx_1 < x_2 < \dots < x_n be positive integers, and let x1x_1 and x2x_2 be relatively prime, so the only positive integer that divides both of them is 11.

Consider every infinite, strictly increasing sequence of integers whose first member is 00 and in which the difference between any two adjacent members equals one of x1,x2,,xnx_1, x_2, \dots, x_n. For example, with n=2n = 2, x1=4x_1 = 4 and x2=7x_2 = 7, the first nine members of such a sequence can be 0,4,8,15,19,26,33,40,440, 4, 8, 15, 19, 26, 33, 40, 44.

Write a program that finds the largest integer appearing in none of these sequences.

Input

The first line contains the integer nn (1<n<61 < n < 6).

The second line contains the integers x1,x2,,xnx_1, x_2, \dots, x_n separated by spaces, with 2x1<x2<<xn100002 \le x_1 < x_2 < \dots < x_n \le 10\,000. The values x1x_1 and x2x_2 are relatively prime.

Output

Print the integer you found on the first line.