#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const int MOD7 = ( int ) 1e9 + 7; int M; vi H; void init(){ cin >> M; int h; while( cin >> h ) if( h ) H.emplace_back( h ); } int n, m; int sum_h; int int_pow( int v, int p ){ int res = v != 0 or p == 0; while( p ){ if( p & 1 ) res = 1LL * res * v % MOD7; p >>= 1; v = 1LL * v * v % MOD7; } return res; } int mod_inv( int v ){ return int_pow( v, MOD7 - 2 ); } int comb( int n, int m ){ int res = 1; for( int i = 2; i <= n; ++i ) res = 1LL * res * i % MOD7; for( int i = 2; i <= m; ++i ) res = 1LL * res * mod_inv( i ) % MOD7; for( int i = 2; i <= n - m; ++i ) res = 1LL * res * mod_inv( i ) % MOD7; return res; } void preprocess(){ for( int i = 0; i < H.size(); ++i ) sum_h += H[ i ]; n = M - ( sum_h + H.size() - 1 ); // number of free balls m = H.size() + 1; // number of choices to put free balls if( n < 0 ) cout << "NA" << endl, exit( 0 ); } void solve(){ cout << comb( m + n - 1, n ) << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }