#define _USE_MATH_DEFINES #include //string stream its useful! #include #include #include //pair #include // vector #include // swap,sort,binary_search #include // std::greater #include //map #include //set #include //queue #include //list #include #include #include #include //cout<,ll> memo; long g(int t){ long x = 1; for(int i = 0 ; i b; b.push_back(k%2); while(k!=0){k>>=1; b.push_back(k%2);} reverse(b.begin(), b.end()); for(auto i = b.begin();i!=b.end();i++){ ans+=*i * a; ans%=W; ans<<=1; } ans>>=1; return ans; } ll getans(long m,vector v , int cursor){ long mysum = accumulate(v.begin(),v.end(), 0L) + v.size() - 1 ; if(mysum == 0 ) return 1; if(mysum == m) return 1; if(mysum > m) return 0; long t = m - (accumulate(v.begin(),v.end(), 0L) + v.size() -1 ) + 1 + v.size() -1 ; long s = v.size(); vector ansl(s); for(int i = 0 ; i l(s+1,0); for(long i = 1; i<=s;i++){ long k = i; for(long j = 2; j<=sqrt(s);j++){ while(k%j == 0) k/=j,l[j]++; } l[k]++; } for(long i = 1; i<=s;i++){ while(l[i]>0){ l[i]--; for(int j = 0 ; jll{return kake(sum,k);})%W; } int main(){ omajinai(); long m; cin>>m; cin.ignore(); vector v; string s; getline(cin,s); stringstream x(s); long t; while(x>>t){v.push_back(t);} string myans = to_string(getans(m,v,0)); if(myans == "0") myans = "NA"; cout<