#include <bits/stdc++.h>
using namespace std;
void Debug() { cerr << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cerr << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = (1 << 30) - 1;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng;
long long fac[MAX_N], inv[MAX_N], fiv[MAX_N];
long long mod_pow(long long a, long long n) {
  if (n == 0) return 1;
  long long res = mod_pow(a, n / 2);
  if (n % 2 == 0)
    return res * res % mod;
  else
    return a * res % mod * res % mod;
}
long long invf(long long a) { return mod_pow(a, mod - 2); }
void C_init(int n) {
  fac[0] = fac[1] = 1;
  inv[1] = 1;
  fiv[0] = fiv[1] = 1;
  for (int i = int(2); i < int(n + 1); i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    fiv[i] = fiv[i - 1] * inv[i] % mod;
  }
}
long long C(int a, int b) {
  if (a < b || a < 0 || b < 0) return 0;
  return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}
int N, K;
long long dp[30][1010];
int A[MAX_N];
void solve() {
  cin >> N >> K;
  C_init(N);
  for (int i = int(0); i < int(N); i++) cin >> A[i];
  dp[0][0] = 1;
  for (int i = int(0); i < int(K); i++) {
    for (int j = int(0); j < int(N + 1); j++) {
      for (int k = int(0); k < int(A[i] + 1); k++) {
        if (j + k <= N)
          dp[i + 1][j + k] =
              (dp[i + 1][j + k] + long long(dp[i][j] * C(N - j, k) % mod *
                                            C(N - k, A[i] - k) % mod)) %
              mod;
      }
    }
  }
  cout << dp[K][N] << "\n";
}
uint32_t rd() {
  uint32_t res;
  res = std::random_device()();
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  cerr << fixed;
  cerr.precision(6);
  rng.seed(rd());
  solve();
  cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
