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