class NCK: ''' 最大値 :N mod ''' def __init__(self,N,mod): self.mod = mod self.N = N self.factmod = [1,1] for i in range(2,self.N+1): self.factmod.append((self.factmod[-1]*i)%self.mod) self.inv = [0,1] for i in range(2, N + 1): self.inv.append((-self.inv[self.mod % i] * (self.mod // i)) % self.mod) self.invfact = [1,1] for i in range(2, N + 1): self.invfact.append((self.invfact[-1]*self.inv[i])%self.mod) def nCk(self,a,b): if a < b: return 0 return ((self.factmod[a]*self.invfact[b]%self.mod)*self.invfact[a-b])%self.mod def invnCk(self,a,b): return ((self.factmod[a-b]*self.invfact[a]%self.mod)*self.factmod[b])%self.mod N = int(input()) lsc = list(map(int,input().split())) sums = sum([(i+1)*lsc[i] for i in range(9)]) mod = 10**9+7 ans = 0 ii = 1 nck = NCK(3*10**5,mod) nn = nck.factmod[N-1] for i in range(9): nn *= nck.invfact[lsc[i]] nn %= mod for i in range(N): ans += ii*sums*nn ii *= 10 ans %= mod ii %= mod print(ans)