using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace No389_1 { public class Program { void Solve(StreamWriter sw) { //--------------------------------- var M = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); var K = H.Length; if (K == 1 && H[0] == 0) { sw.WriteLine(1); return; } if (M < H.Sum() + K - 1) { sw.WriteLine("NA"); return; } var comb = new Combination(M); sw.WriteLine(comb.NCK(M - H.Sum() + 1, K)); //--------------------------------- } static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; new Program().Solve(sw); sw.Flush(); } } public static partial class MathX { public static int GcdEx(int a, int b, out int x, out int y) { if (b == 0) { x = 1; y = 0; return a; } int tx, ty; var gcd = GcdEx(b, a % b, out tx, out ty); x = ty; y = tx - ty * (a / b); return gcd; } } public struct ModInt { public static int Mod = 1000000007; readonly long value; public int Value { get { return (int)value; } } public ModInt Inverse { get { return GetInverse(); } } public ModInt(long value) { value %= Mod; this.value = value < 0 ? value + Mod : value; } ModInt GetInverse() { int x, y; if (MathX.GcdEx(Value, Mod, out x, out y) != 1) { throw new InvalidOperationException("'Value' and 'Mod' must be disjoint."); } return x; } public ModInt Square() { return this * this; } public ModInt Pow(long exp) { if (exp == 0) return 1; if (exp % 2 == 0) return Pow(exp / 2).Square(); return this * Pow(exp - 1); } public static ModInt Parse(string str) { return long.Parse(str); } public static implicit operator ModInt(long value) { return new ModInt(value); } public static ModInt operator +(ModInt left, ModInt right) { return left.value + right.value; } public static ModInt operator -(ModInt left, ModInt right) { return left.value - right.value; } public static ModInt operator *(ModInt left, ModInt right) { return left.value * right.value; } public static ModInt operator /(ModInt left, ModInt right) { return left * right.Inverse; } public override bool Equals(object obj) { if (!(obj is ModInt)) return false; return value == ((ModInt)obj).value; } public override int GetHashCode() { return value.GetHashCode(); } public override string ToString() { return value.ToString(); } } public class Combination { readonly ModInt[] facts; public Combination(int max) { facts = new ModInt[max + 1]; facts[0] = 1; for (var i = 1; i <= max; i++) facts[i] = facts[i - 1] * i; } public ModInt Fact(int n) { return facts[n]; } public ModInt NCK(int n, int k) { if (n < k) return 0; return facts[n] / facts[k] / facts[n - k]; } public ModInt NPK(int n, int k) { if (n < k) return 0; return facts[n] / facts[n - k]; } public ModInt NHK(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return facts[n + k - 1] / facts[k] / facts[n - 1]; } } }