#include #include template struct smallCombinationTable { long table[size][size]; smallCombinationTable() { table[0][0] = 1; for(int i = 1; i < size; ++i) { table[i][0] = table[i][i] = 1; for(int j = 1; j < i; ++j) { table[i][j] = (table[i-1][j-1] + table[i-1][j]) % mod; } } } long operator() (long n, long r) { assert( 0 <= n and n < size ); assert( 0 <= r and r < size ); return table[n][r]; } }; template struct factorialTable { long table[size]; factorialTable() { table[0] = 1; for(int i = 1; i < size; ++i) { table[i] = (table[i-1] * i) % mod; } } long operator() (long n) { assert( 0 <= n and n < size ); return table[n]; } }; template T pow(T x, long n) { T res = 1; T p = x; while( n != 0 ) { if( n & 0x01 ) res *= p; p *= p; n >>= 1; } return res; } template struct Mod { Mod() : a(0) {} Mod(long x) : a(x) {} long get() { return a; } Mod operator + (Mod x) { return Mod

((a + x.get()) % P); } Mod operator += (Mod x) { a = (a + x.get()) % P; return *this; } Mod operator - (Mod x) { return Mod

((a + P - x.get()) % P); } Mod operator -= (Mod x) { a = (a + P - x.a) % P; return *this; } Mod operator * (Mod x) { return Mod

((a * x.get()) % P); } Mod operator *= (Mod x) { a = (a * x.a) % P; return *this; } Mod operator / (Mod x) { return *this * pow(x, P - 2); } Mod operator /= (Mod x) { a = (*this * pow(x, P - 2)); return *this; } long a; }; template struct Combination { factorialTable factorial; long operator() (long n, long r) { Mod res = Mod(factorial(n)) / Mod(factorial(r) * factorial(n-r)); return res.get(); } }; Combination<1123456, 1000000007> combination; int main() { long m; long temp; long total = 0; long count = 0; scanf("%ld\n", &m); for(;;) { int c = getchar(); if( c == '\n' ) break; ungetc(c, stdin); scanf("%ld", &temp); total += temp; count += 1; } if( count == 1 and total == 0 ) { printf("1\n"); return 0; } long n = count + 1; long r = m - total - (count - 1); // printf("(n, r) = (%ld, %ld)\n", n, r); if( r < 0 ) { printf("NA\n"); return 0; } printf("%ld\n", combination(n + r - 1, r)); return 0; }