from operator import mul
from functools import reduce
import random


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


random.seed(0)
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
happiness = [0 for _ in range(n)]
comb_cal = 1

for a in a_list:
    c = cmb(n, a)
    random_num = random.sample([i for i in range(n)], a)
    for r in random_num:
        happiness[r] += 1
    comb_cal *= c

expected = 1
for h in happiness:
    expected *= h
print(comb_cal*expected % (10**9+7))
