시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 91 68 62 75.610%

문제

하나코는 최근에 임의의 음이 아닌 정수를 선택하면 항상 원주율 π = 3.14159265 · · · 의 특정 부분에서 나타난다는 것을 알았습니다. 그 이후, 그녀는 숫자들의 나열이 주어질 때, 그 숫자열에서 나타나는 음이 아닌 정수를 알아보고자 합니다.

예를 들어, "3 0 1"이라는 숫자열이 있다면 이 숫자열에서 나타나는 정수는 3, 0, 1, 30, 301로 총 5가지 있습니다.

하나코는 유한한 길이의 숫자열이 있을 때 이 숫자열에서 나타나지 않는 가장 작은 음이 아닌 정수를 알아보고자 합니다. 앞에서 언급한 숫자열에서는 0, 1이 나타나지만 2가 나타나지 않기 때문에 2가 답이 됩니다.

하나코의 궁금증을 해결해주는 프로그램을 작성해주세요!

입력

입력의 첫 번째 줄에는 숫자열의 길이 N (1 ≤ N ≤ 1,000)이 주어집니다.

입력의 두 번째 줄부터는 D1, D2, ..., DN이 주어집니다. D1 ~ DN은 0 이상 9 이하의 정수이며, Dk와 Dk+1 사이에는 공백이나 줄바꿈 문자가 주어집니다.

출력

입력으로 주어진 수열에서 나타나지 않는 가장 작은 음이 아닌 정수를 출력하세요.

예제 입력 1

3
3 0 1

예제 출력 1

2

예제 입력 2

11
9 8 7 6 5 4 3 2 1 1 0

예제 출력 2

12

예제 입력 3

10
9 0 8 7 6 5 4 3 2 1

예제 출력 3

10

예제 입력 4

100
3 6 7 5 3 5 6 2 9 1 2 7 0 9 3 6 0 6 2
6 1 8 7 9 2 0 2 3 7 5 9 2 2 8 9 7 3 6
1 2 9 3 1 9 4 7 8 4 5 0 3 6 1 0 6 3 2
0 6 1 5 5 4 7 6 5 6 9 3 7 4 5 2 5 4 7
4 4 3 0 7 8 6 8 8 4 3 1 4 9 2 0 6 8 9
2 6 6 4 9

예제 출력 4

11

예제 입력 5

100
7 2 7 5 4 7 4 4 5 8 1 5 7 7 0 5 6 2 0
4 3 4 1 1 0 6 1 6 6 2 1 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