#ifdef __GNUC__ #pragma GCC optimize ("O3") #pragma GCC target ("avx") #endif #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //assert(); #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #define PII pair ///////// using namespace::std; // 最大公約数 template inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);} // 最小公倍数 template inline T lcm(T a, T b){return a * b / gcd(a, b);} //////////////////////////////// const ULL mod = 1000000007; ULL inv[1000010]; ULL invMod(ULL k){//k**(mod-2) // 098765432109876543210987654321 //0b111011100110101100101000000111 ULL p = mod-2; ULL ret = 1; while(p){//30回回る if( p & 1 ){ ret = (ret*k)%mod; } k = (k*k)%mod; p >>= 1; } return ret; } ULL nCk(ULL N,ULL k){ k = min(k,N-k); if( k == 0 ){return 1;} if( k == 1 ){return N%mod;} ULL ret = 1; for(int i=1;i<=k;++i){ ret *= (N+1-i);//OVF ret %= mod; } ULL kkai = 1; for(int i=1;i<=k;++i){ kkai *= i; kkai %= mod; } ret = ( ret*invMod(kkai) ) %mod; return ret; } inline void solve(){ int N; scanf("%d",&N); int temp = 0; int sum = 0; int kind = 0; while( scanf("%d",&temp) != EOF ){ sum += temp; ++kind; } if( sum == 0 ){ printf("1\n"); return; } if( sum + kind-1 > N ){ printf("NA\n"); return; } int aki = N - (sum+kind-1); printf("%d\n", nCk(aki+kind,kind) ); } int main(void){ //std::cin.tie(0); //std::ios::sync_with_stdio(false); //std::cout << std::fixed;//小数を10進数表示 //cout << setprecision(16);//小数をいっぱい表示する。16? solve(); return 0; }