The lady wrote down a sequence of consecutive positive integers on a piece of paper. The first number in this sequence was . For instance, if n = 47 and k = 5, the sequence would be [47, 48, 49, 50, 51]. While she was at school, her younger sister played with the sequence and removed all but one digit from each number, resulting in a sequence of single digits.
When the lady returned from school, she was upset because she couldn't remember the starting number . Your task is to help her find the smallest possible from which the sequence could have started.
The first line contains a single integer (1 \leq k \leq 10^5) — the number of numbers in the sequence.
The second line contains digits b_1, b_2, \dots, b_k (0 \leq b_i \leq 9) — the sequence of digits that the lady found when she returned from school.
Output a single line with the answer — the smallest number from which the lady's sequence could have started.
Example 1
For example, n = 47 results in the sequence [47, 48, 49, 50, 51, 52], from which the lady's younger sister could have removed digits to create the sequence of digits given in the example. Since no smaller will work, the answer is .
( points): 1 \leq k \leq 1000, the correct answer does not exceed ;
( points): 1 \leq k \leq 1000;
( points): 1 \leq k \leq 10^5, all digits in the sequence are the same;
( points): 1 \leq k \leq 10^5.