No Change | 프로그래밍의 벗 PivotOJ
PivotOJ

No Change

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2020-21 finalBOJ 29900

문제

Jack has NN coins, with values M1M_1, M2M_2, \dots, MNM_N. Find the smallest positive amount that cannot be paid with these coins with no change.

입력

The first line contains NN (1N10001 \le N \le 1\,000), the number of coins. The second line contains NN integers MiM_i (1Mi10000001 \le M_i \le 1\,000\,000), the values of the coins.

출력

The only line should contain a single positive integer: the smallest amount that Jack cannot pay with his coins.

예제

예제 1

입력
3
1 2 5
출력
4

예제 2

입력
3
1 2 2
출력
6
코드를 제출하려면 로그인하세요.