#include using namespace std; using ll = long long; ll m = 1e9 + 7; ll mpow(ll a, ll n) { ll ret = 1; while (n) { if (n % 2) { ret *= a; ret %= m; } n /= 2; a = (a * a) % m; } return ret; } int main () { int N; cin >> N; ll kj = 1; ll ans = 0; ll kai[100010]; kai[0] = 1; for (int i = 1; i <= N; i ++) { kai[i] = kai[i - 1] * i; kai[i] %= m; } ll fkai[100010]; fkai[N] = mpow(kai[N], m - 2); for (int i = N; i > 0; i --) { fkai[i - 1] = fkai[i] * i; fkai[i - 1] %= m; } for (int i = 0; i < N; i ++) { ans += kj; if (ans >= m) { ans -= m; } kj *= 10; kj %= m; } kj = 0; ll pk = kai[N]; int num[10]; for (int i = 1; i < 10; i ++) { cin >> num[i]; pk *= fkai[num[i]]; } for (int i = 1; i < 10; i ++) { ll x = pk; x *= num[i]; x %= m; x *= mpow(N, m - 2); x %= m; x *= i; x %= m; kj += x; if (kj >= m) kj -= m; } cout << (ans * kj) % m << endl; }