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

문제

준규는 칠판에 N으로 시작하는 연속하는 양의 정수 K개를 칠판에 써놓았다. 준규가 잠시 화장실에 간 사이에 해빈이는 각각의 숫자에서 한 자리를 제외한 나머지 자리를 모두 지워놓았다. 

해빈이가 지워서 생긴 새로운 수열이 주어졌을 때, 원래 준규가 적은 수열을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 수열의 길이 K가 주어진다. 둘째 줄에는 해빈이가 지워서 만든 수열을 나타내는 K개의 정수 B1, B2, ..., BK가 주어진다. (0 ≤ Bi ≤ 9)

출력

첫째 줄에 가능한 준규 수열 중 N이 가장 작은 것의 N을 출력한다.

서브태스크

번호 배점 제한
1 9

1 ≤ K ≤ 1000, 정답은 1000을 넘지 않는다.

2 33

1 ≤ K ≤ 1000.

3 25

1 ≤ K ≤ 100 000, 입력으로 주어진 수열의 모든 원소는 같다.

4 33

1 ≤ K ≤ 100 000.

예제 입력 1

6
7 8 9 5 1 2

예제 출력 1

47

힌트

준규가 칠판에 적은 수열은 47 48 49 50 51 52이고, N이 47보다 작으면서 가능한 수열은 없다.

W3sicHJvYmxlbV9pZCI6IjEwMDk3IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjMjE4XHVjNWY0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM5MDBcdWFkZGNcdWIyOTQgXHVjZTYwXHVkMzEwXHVjNWQwIE5cdWM3M2NcdWI4NWMgXHVjMmRjXHVjNzkxXHVkNTU4XHViMjk0IFx1YzVmMFx1YzE4ZFx1ZDU1OFx1YjI5NCBcdWM1OTFcdWM3NTggXHVjODE1XHVjMjE4IEtcdWFjMWNcdWI5N2MgXHVjZTYwXHVkMzEwXHVjNWQwIFx1YzM2OFx1YjE5M1x1YzU1OFx1YjJlNC4gXHVjOTAwXHVhZGRjXHVhYzAwIFx1YzdhMFx1YzJkYyBcdWQ2NTRcdWM3YTVcdWMyZTRcdWM1ZDAg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