#include using namespace std; long long n, m = 0; long long c[9], g[200001]; const long long M = 1e9 + 7; long long powm(long long a, long long b) { long long u = 1, v = a; while (b > 0) { if (b & 1) u = u * v % M; b >>= 1; v = v * v % M; } return u; } int main() { cin >> n; for (int i = 0; i < 9; i++) cin >> c[i]; g[0] = 1; for (int i = 1; i < n; i++) g[i] = g[i - 1] * i % M; for (int i = 0; i < 9; i++) { if (c[i] > 0) { long long u = (i + 1) * g[n - 1] % M; for (int j = 0; j < 9; j++) { if (j != i) u = u * powm(g[c[j]], M - 2) % M; else u = u * powm(g[c[j] - 1], M - 2) % M; } m = (m + u) % M; } } m = m * (powm(10, n) - 1) % M * powm(9, M - 2) % M; cout << m << endl; }