#include #include #include #include #include #include #include #include #include #include using namespace std ; #define MAX 1000001 #define MOD 1000000007 pair, vector>, vector> COMinit() { vector fac; fac.push_back(1); fac.push_back(1); vector finv; finv.push_back(1); finv.push_back(1); vector inv; inv.push_back(1); inv.push_back(1); for (int i = 2; i < MAX+1; i++) { fac.push_back(fac[i - 1] * i % MOD); inv.push_back(MOD - ((inv[MOD % i] * (MOD / i)) % MOD)); finv.push_back(finv[i - 1] * inv[i] % MOD); } return make_pair(make_pair(fac, finv), inv); } long long int COM(long long int n, long long int k, pair, vector>, vector> &x) { return x.first.first[n] * x.first.second[k] % MOD * x.first.second[n - k] % MOD; } int main(){ long long int M; cin >> M; vector k; long long int s = 0; for(int i = 0; i < M; i++){ int a; cin >> a; if(a == 0){ cout << 1 << endl; return 0; } if(cin.eof()) break; k.push_back(a); s += a; } if(M-s < k.size()-1){ cout << "NA" << endl; return 0; } long long int ans = 0; pair, vector>, vector> x = COMinit(); ans = COM((k.size()+1)+(M-s-(k.size()-1)-1),(M-s-(k.size()-1)),x); cout << ans << endl; return 0; }