from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) mod = 10**9 + 7 class combination(): def __init__(self,N,p): self.fact = [1, 1] # fact[n] = (n! mod p) self.factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) self.inv = [0, 1] # factinv 計算用 self.p = p for i in range(2, N + 1): self.fact.append((self.fact[-1] * i) % p) self.inv.append((-self.inv[p % i] * (p // i)) % p) self.factinv.append((self.factinv[-1] * self.inv[-1]) % p) def cmb(self,n, r): if (r < 0) or (n < r): return 0 r = min(r, n - r) return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p C = combination(N+3,mod) c = list(map(int,input().split())) s = sum(pow(10,i,mod) for i in range(N))%mod ans = 0 T = C.fact[N] for cc in c: T *= C.factinv[cc] T %= mod Ninv = pow(N,mod-2,mod) for i,cc in enumerate(c): if cc==0: continue ans += (i+1)*s*T*cc*Ninv ans %= mod print(ans)