#include using namespace std; using ll = long long; int main () { int N; cin >> N; ll m = 1e9 + 7; ll kj = 1; ll ans = 0; for (int i = 0; i < N; i ++) { ans += kj; if (ans >= m) { ans -= m; } kj *= 10; kj %= m; } kj = 0; for (int i = 1; i < 10; i ++) { ll x; cin >> x; kj += (x * i) % m; if (kj >= m) kj -= m; } cout << (ans * kj) % m << endl; }