#include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const int mod = 1e9+7; int main() { int n; cin >> n; vector a; map mp; for(int i = 0; i < 9; i++){ cin >> mp[i+1]; if(mp[i+1] > 0) a.push_back(i+1); } ll ans = 0, tmp = 1; ll num = 1; for(int i = a.size()-1; i >= 1; i--) num *= i; for(int i = 0; i < n; i++){ //cout << "----" << tmp << "----" << endl; for(int j : a){ //cout << "j: " << j << " num[j]: " << mp[j] << endl; ans = ans+((((j*tmp)%mod)*num)%mod)*mp[j]%mod; ans %= mod; } tmp *= 10; } cout << ans << endl; return 0; }