N = int(input()) c = list(map(int,input().split())) M = 0 i = 8 while N > 0: if c[i] > 0: M += (i+1) * (10 ** (N-1)) N -= 1 c[i] -= 1 else: i -= 1 print(M)