cho.sh
Notes
Loading...

Making a Number

Time limit

2s

Memory limit

128 MB

Problem

Sejun has digit cards numbered from 0 through 9. Each card contains one digit, and he may choose some or all of the given cards to make one number.

The number must not start with 0, and no two adjacent digits may be the same. If only 0 can be made, the one-digit number 0 is allowed.

Given how many cards Sejun has for each digit, find the largest number that can be made while satisfying these rules.

Input

The first line contains 10 integers: the number of cards for digits 0 through 9, in order. The total number of cards is at least 1 and at most 50.

Output

Print the largest number that can be made while satisfying the rules.