Let x1<x2<⋯<xn be positive integers, and let x1 and x2 be relatively prime, so the only positive integer that divides both of them is 1.
Consider every infinite, strictly increasing sequence of integers whose first member is 0 and in which the difference between any two adjacent members equals one of x1,x2,…,xn. For example, with n=2, x1=4 and x2=7, the first nine members of such a sequence can be 0,4,8,15,19,26,33,40,44.
Write a program that finds the largest integer appearing in none of these sequences.
The first line contains the integer n (1<n<6).
The second line contains the integers x1,x2,…,xn separated by spaces, with 2≤x1<x2<⋯<xn≤10000. The values x1 and x2 are relatively prime.
Print the integer you found on the first line.