import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

MOD = 1000000007

N ,K = map(int, input().split())
a_list = list(map(int, input().split()))
child_cnt_list = [0] * N

for i in range(K):
  for j in range(a_list[i]):
    child_cnt_list[j] += 1

result = 1
for i in range(N):
  result = (result * (child_cnt_list[i])) % MOD

for i in range(K):
  result = (result * comb(N, a_list[i])) % MOD

print(result)