시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB86250.000%

문제

Let x1 < x2 < … < xn be positive integers and let x1 and x2 be relatively prime (i.e. the only positive integer that evenly divides both of them is 1).

We consider all infinite sequences of integers, which are strictly increasing with first member 0, for which the difference between any two adjacent members is equal to one of the integers x1, x2, …, xn. For example, if n = 2, x1 = 4 and x2 = 7, then the first nine members of such a sequence are possible to be 0, 4, 8, 15, 19, 26, 33, 40, 44.

Write program sequence that determines the largest integer that cannot be found in any of these sequences. 

입력

The integer n (1 < n < 6) is given on the first line of the standard input. There are n integers on the second line: x1, x2, …, xn

출력

On a line of the standard output the program have to write the sought integer.

서브태스크

번호배점제한
140

1 < n < 6, x1 > 1, xn < 1000

224

n = 2, x1 > 1, xn < 109

336

1 < n < 6, 1 < x1 < 106-n, x2 > 10n+11, xn < 10n+12

예제 입력 1

2
4 7

예제 출력 1

17

채점 및 기타 정보

  • 예제는 채점하지 않는다.