#include using namespace std ; typedef long long ll ; typedef pair P ; #define rep(i,n) for(int i = 0 ; i < n ; i++) #define rrep(i,a,b) for(int i = a ; i < b ; i++) #define chmin(a,b) a = min(a,b) ; const int mod = 1000000007 ; ll n , k ; vector digit ; ll fac[202020] ; ll inv[202020] ; ll C[10] ; ll powmod(ll x , ll n){ ll res = 1 ; while(n > 0){ if(n & 1) (res *= x) %= mod ; (x *= x) %= mod ; n >>= 1 ; } return res ; } void init(){ fac[0] = fac[1] = 1 ; rrep(i,2,202020) fac[i] = fac[i-1] * i % mod ; inv[0] = inv[1] = 1 ; rrep(i,2,202020) inv[i] = inv[i-1] * powmod(i,mod-2) % mod ; } int main(){ init() ; cin >> n ; rep(i,9) cin >> C[i] ; ll res = 0 ; rep(i,n){ rep(j,9){ if(C[j] == 0) continue ; ll val = fac[n-1] * inv[C[j] - 1] % mod * (j + 1) % mod * powmod(10,i) ; rep(k,9) if(j != k) (val *= inv[C[k]]) %= mod ; (res += val) %= mod ; } } cout << res << endl ; }