#include <bits/stdc++.h>
using namespace std;
constexpr long long int MOD = 1000000007;
constexpr double EPS = 1e-8;
long long int N, M, K, H, W, L, R;
long long int power(long long int x, long long int n, long long int M) {
  long long int ret = 1;
  long long int by = x;
  while (n) {
    if (n & 1) {
      ret *= by;
      ret %= M;
    }
    by *= by;
    by %= M;
    n >>= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  vector<int> v(K);
  for (auto &i : v) cin >> i;
  vector<int> u(N);
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < v[i]; j++) u[j]++;
  }
  vector<long long int> by(N + 1, 1);
  vector<long long int> rev(N + 1, 1);
  for (int i = 1; i <= N; i++) {
    by[i] = by[i - 1] * i % MOD;
    rev[i] = power(by[i], MOD - 2, MOD);
  }
  for (int i = 1; i < N; i++) {
    u[i] += u[i - 1];
  }
  auto l = u;
  reverse(l.begin(), l.end());
  for (auto &i : l) i = u.back() - i;
  vector<vector<int>> dp(2, vector<int>(u.back() + 1));
  for (int i = l[0]; i <= u[0]; i++) {
    dp[0][i] = i;
  }
  for (int i = 1; i < N; i++) {
    int bef = (i - 1) & 1;
    int c = i & 1;
    for (int j = l[i]; j <= u[i]; j++) {
      dp[c][j] = 0;
    }
    for (int j = l[i - 1]; j <= u[i - 1]; j++) {
      if (!dp[bef][j]) continue;
      for (int cnum = 1; cnum <= K; cnum++) {
        if (j + cnum < l[i]) {
          cnum = l[i] - j - 1;
          continue;
        }
        if (j + cnum > u[i]) break;
        dp[c][j + cnum] += 1LL * dp[bef][j] * cnum % MOD;
        dp[c][j + cnum] %= MOD;
      }
    }
  }
  int c = (N - 1) & 1;
  long long int ans = 0;
  ans = dp[c].back();
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
