#include using namespace std; #define int long long const int MOD = 1000000000 + 7; int Factorial(int n) { int res = 1; while (n) (res *= n--) %= MOD; return res; } int Pow(int x, int n) { if (n == 0) return 1; int res = Pow(x*x % MOD, n/2); if (n&1) res *= x; return res % MOD; } int Inverse(int n) { return Pow(n, MOD - 2); } int H(int ball, int stick) { return Factorial(ball + stick) * Inverse(Factorial(ball) * Factorial(stick) % MOD) % MOD; } int M; signed main() { cin >> M; int h, sum = 0, N = 0; while (cin >> h) { sum += h; N++; } if (h == 0) sum = 0, N = 0; if (sum + N - 1 > M) { puts("NA"); return 0; } int n = M - (sum + N - 1), k = N; printf("%lld\n", H(n, k)); return 0; }