// #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

// #include <atcoder>
// using namespace atcoder;
// using mint = modint1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Bdouble = mp::number<mp::cpp_dec_float<32>>;

const int MOD = 1000000007;

vector<ll> 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;
    ll ans = 0;
    ll cntfinv = 1;
    for (ll i = 0; i < 9; i++) {
        ll c;
        cin >> c;
        ll 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;
}