// No.1628 Sorting Integers (MAX of M) package main import ( "fmt" "strconv" "strings" ) func reverse(s string) string { rs := []rune(s) for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { rs[i], rs[j] = rs[j], rs[i] } return string(rs) } func main() { var n int fmt.Scan(&n) var c = make([]int, 9) for i := 0; i < 9; i++ { fmt.Scan(&c[i]) } var s string for j := 0; j < 9; j++ { s += strings.Repeat(strconv.Itoa(j+1), c[j]) } fmt.Println(reverse(s)[0:n]) }