from itertools import permutations input() C = list(map(int, input().split())) res = [] for i in range(9): res += [i+1] * C[i] ans = 0 for v in permutations(res): ans = max(ans, int(''.join(list(map(str, v))))) print(ans)