import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) sys.setrecursionlimit(10**7) yes = lambda :print("yes");Yes = lambda :print("Yes") no = lambda :print("no");No = lambda :print("No") ####################################################################### n = ni() c = na() mod = 10**9+7 z = 1 f = 1 for i in range(1,n): f*=i for i in range(9): for j in range(1,c[i]+1): f*=pow(j,mod-2,mod) ans = 0 for i in range(n): for j in range(9): ans+=f*z%mod*c[j]%mod*(j+1)%mod ans%=mod z*=10 z%=mod print(ans)