Codeforces Round 202 (Div. 2)
B
Color the Fence
Codeforces
1700
原题
← AC →
翻译中…

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.

翻译中…

Unfortunately, Igor could only get $*v*$ liters of paint. He did the math and concluded that digit $*d*$ requires $*a*_{*d*}$ liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number.

翻译中…

Help Igor find the maximum number he can write on the fence.

翻译中…

Input

翻译中…

The first line contains a positive integer $*v*$ $(0 ≤ *v* ≤ 10^{6})$. The second line contains nine positive integers $*a*_{1}, *a*_{2}, ..., *a*_{9}$ $(1 ≤ *a*_{*i*} ≤ 10^{5})$.

翻译中…

Output

翻译中…

Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1.

翻译中…

样例

Input #1
5
5 4 3 2 1 2 3 4 5
Output #1
55555
InputCopy OutputCopy
Input #2
2
9 11 1 12 5 8 9 10 6
Output #2
33
InputCopy OutputCopy
Input #3
0
1 1 1 1 1 1 1 1 1
Output #3
-1
InputCopy OutputCopy
题目信息
题号
349B
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。