import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } const long mod = cast(long)(1e9 + 7); long extgcd(long a, long b, ref long x, ref long y) { long g = a; x = 1; y = 0; if (b != 0) { g = extgcd(b, a % b, y, x); y -= (a / b) * x; } return g; } long inverse(long mod, long v) { long x, y; if (extgcd(v, mod, x, y) == 1) return (x + mod) % mod; return 0; } void main() { int M; readf("%d\n", &M); auto H = readln.chomp.split(" ").map!(to!int).array; int k = H.size; if (k == 1 && H[0] == 0) { writeln(1); return; } int Y = M - (k - 1); foreach (h; H) { Y -= h; } if (Y < 0) { writeln("NA"); return; } auto inv = delegate(long x) => inverse(mod, x); long ans = 1; for (long i = 1; i <= Y + k; i++) { ans = (ans * i) % mod; } for (long i = 1; i <= k; i++) { ans = (ans * inv(i)) % mod; } for (long i = 1; i <= Y; i++) { ans = (ans * inv(i)) % mod; } writeln(ans); }