伊戈尔爱上了达尼雅。现在伊戈尔想表达自己的感情,在谭雅家对面的栅栏上写一个数字。伊戈尔认为,数字越大,赢得谭雅心的机会就越大。
不幸的是,伊戈尔只能得到 v 升油漆。他做了数学计算,并得出结论,数字d需要一个ad升油漆。此外,伊戈尔听说谭雅不喜欢零。这就是为什么伊戈尔不会在他的号码中使用它们。
帮助伊戈尔找到他可以在栅栏上写的最大数字。
Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has.
5 5 4 3 2 1 2 3 4 5
55555
2 9 11 1 12 5 8 9 10 6
33
0 1 1 1 1 1 1 1 1 1
-1
第一行包含一个正整数 v (0≤V≤106).第二行包含九个正整数一个1,a2,...,a9 (1≤ai≤105).
打印伊戈尔可以在栅栏上写入的最大数量。如果他的颜料太少,无法容纳任何数字(因此,他无法书写任何内容),请打印 -1。
Input
5
5 4 3 2 1 2 3 4 5
Output
55555
Input
2
9 11 1 12 5 8 9 10 6
Output
33
Input
0
1 1 1 1 1 1 1 1 1
Output
-1
0
1 1 1 1 1 1 1 1 1
-1