#include using namespace std; using ll = long long; const ll modc=1e9+7, MAX=1000000; vector f, finv; ll mod_exp(ll b, ll e, ll m){ if (e > 0 && b == 0) return 0; ll ans = 1; b %= m; while (e > 0){ if ((e & 1LL)) ans = (ans * b) % m; e = e >> 1LL; b = (b*b) % m; } return ans; } ll inv(ll x){ ll ans = 1, e = modc-2; x %= modc; while (e > 0){ if ((e & 1LL)) ans = (ans * x) % modc; e = e >> 1LL; x = (x*x) % modc; } return ans; } void init(){ f.resize(MAX+1); finv.resize(MAX+1); f[0] = 1; for (int i=1; i<=MAX; i++) f[i] = (f[i-1]*i) % modc; finv[MAX] = inv(f[MAX]); for (int i=MAX-1; i>=0; i--) finv[i] = (finv[i+1] * (i+1)) % modc; } ll P(ll n, ll k){ if (n < k || k < 0) return 0; return (f[n] * finv[n-k]) % modc; } int main(){ init(); ll N, ans=0, cnt; cin >> N; vector c(10); for (int i=1; i<=9; i++) cin >> c[i]; for (int i=1; i<=9; i++){ if (c[i] == 0) continue; cnt = P(N-1, N-1); for (int j=1; j<=9; j++){ if (i == j){ cnt *= inv(P(c[j]-1, c[j]-1)); cnt %= modc; } else{ cnt *= inv(P(c[j], c[j])); cnt %= modc; } } ans += (cnt*i) % modc; ans %= modc; } cnt = (mod_exp(10, N, modc) - 1) * inv(9) % modc; cout << (cnt * ans) % modc << endl; return 0; }