The package for this problem was not updated by the problem writer or Codeforces administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then the value 800 ms will be displayed and used to determine the verdict.

Codeforces Round 202 (Div. 2) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

data structures

dp

greedy

implementation

*1700

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Color the Fence

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputIgor 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.

Examples

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

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/04/2023 10:07:59 (l2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|