from itertools import permutations import math n = int(input()) c = list(map(int,input().split())) fac_arr = [1] * (n+1) r_s_fac_arr = [1] * (n+1) mod = 10 ** 9 + 7 for i in range(1,n+1): fac_arr[i] = (fac_arr[i-1] % mod) * i % mod r_s_fac_arr[i] = (r_s_fac_arr[i-1] % mod) * pow(i,mod-2,mod) % mod ans = 0 nn = fac_arr[n] for i in range(9): if c[i] != 0: nn = nn * r_s_fac_arr[c[i]] % mod ans = 0 nn = nn * pow(n,mod-2,mod) % mod for i in range(9): if c[i] != 0: for j in range(n): ans = (ans + (i+1) * nn * c[i] * pow(10,j,mod)) % mod print(ans)