import typing from math import factorial import numpy as np def main() -> typing.NoReturn: mod = 10 ** 9 + 7 n = int(input()) *c, = map( int, input().split(), ) m = factorial(n) for x in c: m //= factorial(x) c = np.array(c) a = m // n * c d = 10 ** np.arange(n) d = d.sum() % mod s = d * a s *= np.arange(9) + 1 print(s.sum() % mod) main()