using System; using System.Linq; namespace No389{ public class Program{ public static void Main(string[] args){ var M = int.Parse(Console.ReadLine()); var Hk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).Where(x => x != 0); var sum = Hk.Sum(); var k = Hk.Count(); if(k == 0){ Console.WriteLine(1); return; } if(sum + k - 1 > M){ Console.WriteLine("NA"); return; } //TLE var seq = Enumerable.Range(1, M - sum + 1).ToList(); foreach(var er in Enumerable.Range(1, M - sum - k + 1)){ seq[seq.FindIndex(x => x % er == 0)] /= er; } foreach(var er in Enumerable.Range(1, k)) { seq[seq.FindIndex(x => x % er == 0)] /= er; } Console.WriteLine(seq.Aggregate(1L, (x, y) => x * y % 1000000007)); } } }