시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB106615659.574%

문제

Jack has $N$ coins, with values $M_1$, $M_2$, \dots, $M_N$. Find the smallest positive amount that cannot be paid with these coins with no change.

입력

The first line contains $N$ ($1 \le N \le 1\,000$), the number of coins. The second line contains $N$ integers $M_i$ ($1 \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

예제 출력 1

4

These coins can be used to pay the amounts $1$, $2$, and $3 = 1 + 2$, but it's not possible to pay the amount $4$ exactly.

예제 입력 2

3
1 2 2

예제 출력 2

6

These coins can be used to pay any amount from $1$ to $5$, but there's just not enough money to pay the amount $6$.