#include using namespace std; #define rep(i,a,n) for(int i=(a); i<(n); i++) #define rrep(i,a,n) for(int i=(a); i>=(n); i--) #define all(n) begin(n),end(n) #define rall(n) rbegin(n),rend(n) //#define yn(bool) if(bool){cout<; using vl = vector; ll myceil(ll a,ll b){return (a+(b-1))/b;} ll myfloor(ll a,ll b){return a/b;} template inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;} template inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;} void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } void _main() { int n; cin>>n; vi a(9); rep(i,0,9) cin>>a[i]; vector b; rep(i,0,9) { int an = a[i]; rep(j,0,an) b.push_back((i+1)+'0'); } sort(all(b)); ll ans=0; do{ string k; rep(i,0,n) { k+=b[i]; } ans+=stoll(k)%1000000007; ans%=1000000007; }while(next_permutation(all(b))); cout<