#n = 3
#k = 2
#a_list = [3,2]

n, k = map(int, input().split())
a_list = list(map(int, input().split()))

def pow_k(x, n):
  if n == 0:
    return 1

  K = 1
  while n > 1:
    if n % 2 != 0:
      K *= x
    x *= x
    n //= 2

  return K * x

from operator import mul
from functools import reduce
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

mod = 1000000007

# expected value
import math
c_sum = sum(a_list)
#e_v = (math.floor(c_sum/n)+1)**(c_sum%n) * ((math.floor(c_sum/n))**(n-c_sum%n))
e_v = ((pow_k((math.floor(c_sum/n)+1), c_sum%n) % mod) * (pow_k((math.floor(c_sum/n)), n-c_sum%n) % mod)) % mod


# combination
#from itertools import combinations
c_multi = 1
for a in a_list:
#  c_multi = c_multi * len(list(combinations(range(n), a))) % mod
  c_multi = ((c_multi % mod) * (cmb(n, a) % mod)) % mod

print((e_v * c_multi) % mod)