def per(n: int, r: list, mod: int): """同じものを含む順列の計算""" global fact, factinv num = fact[n] for i in r: if i: num *= factinv[i] num %= mod return num n = int(input()) c = list(map(int, input().split())) mod = 10**9 + 7 # n までのそれぞれの階乗計算(mod 含む) fact = [1, 1] factinv = [1, 1] for i in range(2, n+1): fact.append(fact[-1] * i % mod) factinv.append(pow(fact[-1], mod - 2, mod)) cnt = 0 for i in range(9): check = False if c[i]: c[i] -= 1 cnt += per(n - 1, c, mod) * (i + 1) % mod c[i] += 1 # print(cnt) ans = 0 for i in range(n): ans += cnt * pow(10, i) ans %= mod print(ans)