N = int(input()) C = list(map(int, input().split())) mod = 10 ** 9 + 7 n = 505050 fact = [1] * (n + 1) invfact = [1] * (n + 2) for i in range(1, n): fact[i + 1] = ((i+1) * fact[i]) % mod invfact[n] = pow(fact[n], mod - 2, mod) for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % mod invfact[-1] = 0 v = 1 for i in range(N-1): v = 10 * v + 1 v %= mod ans = 0 for i in range(9): cnt = fact[N - 1] for j in range(9): if j != i: cnt *= invfact[C[j]] else: cnt *= invfact[C[j] - 1] cnt %= mod # print(i, cnt) ans += v * (i + 1) * cnt ans %= mod print(ans)