#include using namespace std; using ll = long long; int main(){ int n; cin >> n; int c[10]; for(int i = 1 ; i < 10 ; i++)cin >> c[i]; ll mod = 1000000007; ll fact[n + 1]; ll fact_inv[n + 1]; ll inv[n + 1]; fact[0] = 1; fact[1] = 1; fact_inv[0] = 1; fact_inv[1] = 1; inv[1] = 1; for(int i = 2 ; i <= n ; i++){ fact[i] = fact[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; fact_inv[i] = fact_inv[i - 1] * inv[i] % mod; } ll keisuu[10]; for(int i = 1 ; i < 10 ; i++){ if(c[i] == 0){ keisuu[i] = 0; continue; } keisuu[i] = fact[n - 1]; for(int j = 1 ; j <= 9 ; j++){ if(j == i){ keisuu[i] *= fact_inv[c[i] - 1]; keisuu[i] %= mod; } if(j != i){ keisuu[i] *= fact_inv[c[j]]; keisuu[i] %= mod; } } } ll keisuu_sum = 0; for(int i = 1 ; i < 10 ; i++)keisuu_sum += keisuu[i]; ll ten[n + 1]; ten[0] = 1; ll ans = 1; for(int i = 1 ; i < n ; i++){ ten[i] = ten[i - 1] * 10; ten[i] %= mod; ans += ten[i]; ans %= mod; } ans *= keisuu_sum; ans %= mod; cout << ans << endl; return 0; }