515C.md (1611B)
1 Source: https://codeforces.com/problemset/problem/515/C 2 3 C. Drazil and Factorial 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Drazil is playing a math game with Varda. 22 23 Let's define  for positive integer *x* as a product of factorials of its digits. For example, . 24 25 First, they choose a decimal number *a* consisting of *n* digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number *x* satisfying following two conditions: 26 27 1. *x* doesn't contain neither digit 0 nor digit 1. 28 29 2.  = . 30 31 Help friends find such number. 32 33 Input 34 35 The first line contains an integer *n* (1 ≤ *n* ≤ 15) — the number of digits in *a*. 36 37 The second line contains *n* digits of *a*. There is at least one digit in *a* that is larger than 1. Number *a* may possibly contain leading zeroes. 38 39 Output 40 41 Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. 42 43 Examples 44 45 Input 46 47 ``` 48 4 49 1234 50 ``` 51 52 Output 53 54 ``` 55 33222 56 ``` 57 58 Input 59 60 ``` 61 3 62 555 63 ``` 64 65 Output 66 67 ``` 68 555 69 ``` 70 71 Note 72 73 In the first case, 