#include using namespace std; constexpr int Inf = 2000000000; constexpr long long INF= 2000000000000000000; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template T modpow(T N, U P, T M = -1) { if(P < 0) return 0; T ret = 1; if(M != -1) ret %= M; while(P) { if(P & 1) { if(M == -1) ret *= N; else ret = ret * N % M; } P /= 2; if(M == -1) N *= N; else N = N * N % M; } return ret; } constexpr long long MOD = 1000000007; struct Comb { int size; long long mod; std::vector factorial; std::vector inversion_factorial; std::vector inversion; Comb(int n,long long mod): size(n),mod(mod) { factorial.resize(n + 1); inversion_factorial.resize(n + 1); inversion.resize(n + 1); factorial[0] = factorial[1] = 1; inversion_factorial[0] = inversion_factorial[1] = 1; inversion[1] = 1; for (long long i = 2; i <= n; i++) { factorial[i] = factorial[i - 1] * i % mod; inversion[i] = mod - inversion[mod % i] * (mod / i) % mod; inversion_factorial[i] = inversion_factorial[i - 1] * inversion[i] % mod; } } long long comb(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return factorial[n] * (inversion_factorial[k] * inversion_factorial[n - k] % mod) % mod; } }; int main() { int n; cin >> n; vector vec(9); for(auto& x: vec) cin >> x; Comb comb(n,MOD); long long base = 0; for(int i = 0;i < n;i++) { base += modpow(10ll,i,MOD); base %= MOD; } long long ret = 0; for(int i = 0;i < 10;i++) { if(vec[i] != 0) { long long res = 1; vec[i]--; int remain = n - 1; for(int j = 0;j < 10;j++) { res *= comb.comb(remain,vec[j]); res %= MOD; remain -= vec[j]; } vec[i]++; ret += res * base % MOD * (i + 1) % MOD; ret %= MOD; } } cout << ret << endl; }