#include #include #include #include using namespace std; int kaijo(long a){ long n=1; if (a > 0){ for (long i = a; i > 0; i--){ n *= i; n = n % 1000000007; } } else{ n = 1; } return n; } int permtation(long a,long b){ long n = 1; if (b != 0){ for (long i = 0; i < b; i++){ n *= (a-i); n = n % 1000000007; } } else{ n = 1; } return n; } int main(){ long m; long a = 0; string s; string s1; long h; long cnt = 0; long ans; long p, k; cin >> m; cin.ignore(); getline(cin, s); while (1){ s1 = s; //cout << s1 << endl; a = s1.find(" ", 0); if (a == -1){ h = stoi(s1); m -= h; cnt++; break; } else{ s1.erase(a,s1.length()); h = stoi(s1); m -= h; cnt++; s.erase(0, a + 1); //cout << s << endl; } } long judge = m - cnt + 1; //cout << m << endl; //cout << cnt << endl; //cout << judge << endl; if (judge <0){ cout << "NA" << endl; } else{ if (judge>cnt){ p = permtation(m + 1, cnt); k = kaijo(cnt); while (1){ ans = p / k; if (ans*k == p){ cout << ans << endl; break; } else{ p += 1000000007; } } } else{ p = permtation(m + 1, judge); k = kaijo(judge); while (1){ ans = p / k; if (ans*k == p){ cout << ans << endl; break; } else{ p += 1000000007; } } } //ans = kaijo(m + 1) / (kaijo(m - cnt + 1)*kaijo(cnt)); //cout << ans << endl; //cout << m << endl; } return 0; }