#include #include #include #include using namespace std; typedef long long LL; int main() { int N,i; cin >> N; vector myVec; for (i = 1; i <= 9;i++) { int c; cin >> c; for (int j = 0; j < c; j++) { myVec.push_back(i); } } LL Max = 0; do { LL M = 0; int Len = myVec.size(); for (i = 0; i < myVec.size(); i++) { M += myVec[i] * pow(10.0, Len - 1); Len--; } if (Max < M) { Max = M; } } while (next_permutation(myVec.begin(), myVec.end())); cout << Max << endl; return 0; }