m = 1000000007 N, *c = map(int, open(0).read().split()) fac = [1] * 10 for i in range(9): fac[i + 1] = fac[i] * (i + 1) fac[i + 1] %= m x = 1 for i in range(N - 1): x *= i + 1 x %= m x *= (pow(10, N, m) + (m - 1)) % m * pow(9, -1, m) % m result = 0 for i in range(9): result += c[i] * (i + 1) * x result %= m for i in range(9): result *= pow(fac[c[i]], -1, m) result %= m print(result)