n=int(input()) c=list(map(int,input().split())) fact=[1]*(n+1) mod=10**9+7 for i in range(1,n+1): fact[i]=fact[i-1]*i%mod ans=fact[n-1]*(pow(10,n,mod)-1)*pow(9,mod-2,mod)%mod for i in c: ans=ans*pow(fact[i],mod-2,mod)%mod num=0 for i in range(9): num+=(i+1)*c[i] print(num*ans%mod)