#include #include #include #include #include using namespace std; const long long MOD = 1e9 + 7; int main() { int m, x; cin >> m; vector h(m); int blocks = 0; int total = 0; while (cin >> x) { total += x; blocks++; } int rest = m - total - (blocks - 1); // printf("%d %d %d\n", rest, blocks, total); if (rest < 0) { cout << "NA" << endl; return 0; } else if (total == 0) { cout << 1 << endl; return 0; } //(blocks + rest)C(rest) long long ans = 1; for (long long i = blocks + rest; i > 1; i--) { ans = ans * i % MOD; } long long denominator = 1; for (long long i = blocks; i > 1; i--) { denominator = denominator * i % MOD; } for (long long i = rest; i > 1; i--) { denominator = denominator * i % MOD; } vector pows(31, 1); pows[1] = denominator; for (int i = 2; i < pows.size(); i++) { pows[i] = pows[i - 1] * pows[i - 1] % MOD; } int p2 = MOD - 2; long long inv_denom = 1; for (int i = 31; i >= 0; i--) { if ((p2 >> i) & 1) { inv_denom = inv_denom * pows[i] % MOD; } } // printf("ans %lld\n", ans); // printf("denom %lld\n", denominator); // printf("inv %lld\n", inv_denom); ans = ans * inv_denom % MOD; cout << ans << endl; return 0; }