#include #include #include using namespace std; using i64 = long long; constexpr i64 mod = i64(powl(10, 9)) + 7; tuple extgcd(i64 x, i64 y) { if(y == 0) { return make_tuple(1, 0, x); } i64 a, b, d; tie(a, b, d) = extgcd(y, x%y); return make_tuple(b, a-x/y*b, d); } i64 mod_inv(const i64 &a, const i64 &m) { i64 x, _, d; tie(x, _, d) = extgcd(a, m); if(d == 1) { return (x % m + m) % m; } throw; } i64 nCr(i64 n, i64 r, i64 mod) { vector fact(n+1, 1); for(i64 i=2; i<=n; ++i) { fact[i] = fact[i-1] * i; fact[i] %= mod; } i64 inv1 = mod_inv(fact[r], mod), inv2 = mod_inv(fact[n-r], mod); i64 res = fact[n]; res *= inv1; res %= mod; res *= inv2; res %= mod; return res; } int main(void) { i64 m; scanf("%lld", &m); vector a; for(i64 x; ~scanf("%lld", &x); a.push_back(x)) ; i64 n = a.size(); i64 acc = accumulate(begin(a), end(a), 0); if(a[0] == 0) { puts("1"); return 0; } if(acc + n - 1 > m) { puts("NA"); return 0; } i64 res = nCr(m-acc+1, n, mod); printf("%lld\n", res); return 0; }