""" """ import sys from sys import stdin def modfac(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): inv *= m inv %= MOD invs[m - 1] = inv return factorials, invs def modnCr(n,r): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる) return fac[n] * inv[n-r] * inv[r] % mod mod = 10**9+7 fac,inv = modfac(300000,mod) N = int(stdin.readline()) c = list(map(int,stdin.readline().split())) ans = 0 ds = 0 for i in range(N): ds += pow(10,i,mod) ds %= mod for i in range(9): v = i+1 if c[i] != 0: now = modnCr(N-1,c[i]-1) rem = N-c[i] for j in range(9): if j != i: now *= modnCr(rem,c[j]) rem -= c[j] ans += now * ds * v print (ans % mod)