n = int(raw_input())
b = [0 for i in range(n)]
for i in range(n):
b[i] = int(raw_input())
a = [0]
for sumDig in b:
suff = 0
for x in a:
suff += x
for i in range(10000):
if len(a) == i:
a.append(0)
suff -= a[i]
found = False
for dig in range(a[i] + 1, 10):
if dig + suff <= sumDig and sumDig <= dig + suff + i * 9:
a[i] = dig
need = sumDig - dig - suff
for t in range(0, i):
a[t] = min(need, 9)
need -= a[t]
found = True
break
if found:
break
res = ''
ok = False
for i in range(len(a) - 1, -1, -1):
if a[i] != 0:
ok = True
if ok:
res += str(a[i])
print res
biA9IGludChyYXdfaW5wdXQoKSkKYiA9IFswIGZvciBpIGluIHJhbmdlKG4pXQpmb3IgaSBpbiByYW5nZShuKToKICAgIGJbaV0gPSBpbnQocmF3X2lucHV0KCkpCmEgPSBbMF0KZm9yIHN1bURpZyBpbiBiOgogICAgc3VmZiA9IDAKICAgIGZvciB4IGluIGE6CiAgICAgICAgc3VmZiArPSB4CiAgICBmb3IgaSBpbiByYW5nZSgxMDAwMCk6CiAgICAgICAgaWYgbGVuKGEpID09IGk6CiAgICAgICAgICAgIGEuYXBwZW5kKDApCiAgICAgICAgc3VmZiAtPSBhW2ldCiAgICAgICAgZm91bmQgPSBGYWxzZQogICAgICAgIGZvciBkaWcgaW4gcmFuZ2UoYVtpXSArIDEsIDEwKToKICAgICAgICAgICAgaWYgZGlnICsgc3VmZiA8PSBzdW1EaWcgYW5kIHN1bURpZyA8PSBkaWcgKyBzdWZmICsgaSAqIDk6CiAgICAgICAgICAgICAgICBhW2ldID0gZGlnCiAgICAgICAgICAgICAgICBuZWVkID0gc3VtRGlnIC0gZGlnIC0gc3VmZgogICAgICAgICAgICAgICAgZm9yIHQgaW4gcmFuZ2UoMCwgaSk6CiAgICAgICAgICAgICAgICAgICAgYVt0XSA9IG1pbihuZWVkLCA5KQogICAgICAgICAgICAgICAgICAgIG5lZWQgLT0gYVt0XQogICAgICAgICAgICAgICAgZm91bmQgPSBUcnVlCiAgICAgICAgICAgICAgICBicmVhawogICAgICAgIGlmIGZvdW5kOgogICAgICAgICAgICBicmVhawogICAgcmVzID0gJycKICAgIG9rID0gRmFsc2UKICAgIGZvciBpIGluIHJhbmdlKGxlbihhKSAtIDEsIC0xLCAtMSk6CiAgICAgICAgaWYgYVtpXSAhPSAwOgogICAgICAgICAgICBvayA9IFRydWUKICAgICAgICBpZiBvazoKICAgICAgICAgICAgcmVzICs9IHN0cihhW2ldKQogICAgcHJpbnQgcmVz