// #define _GLIBCXX_DEBUG #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ld = long double; using P = pair; // #include // using namespace atcoder; // using mint = modint1000000007; // #include // #include // namespace mp = boost::multiprecision; // using Bint = mp::cpp_int; // using Bdouble = mp::number>; const int MOD = 1000000007; vector fac(200200), finv(200200), inv(200200); bool is_preprocessing_already_done = 0; void preprocessing() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 200200; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll comb(int n, int k) { if (!is_preprocessing_already_done) { preprocessing(); is_preprocessing_already_done = 1; } if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; long ans = 0; long cntfinv = 1; for (int i = 0; i < 9; i++) { long c; cin >> c; long cnt = i + 1; for (int j = 0; j < n - 1; j++) { cnt *= 10; cnt += i + 1; } ans += cnt * comb(n - 1, n - c); ans %= MOD; cntfinv *= finv[c]; } ans *= fac[n - 1] * cntfinv; ans %= MOD; cout << ans << endl; return 0; }