#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long dp[k + 1][n + 1], comb[n + 1][n + 1];
  memset(comb, 0, sizeof comb);
  comb[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++)
      comb[i][j] = ((j > 0 ? comb[i - 1][j - 1] : 0) + comb[i - 1][j]) % M;
  for (int i = 0; i <= n; i++) dp[0][i] = i == 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j <= n; j++) {
      long long sum = 0;
      for (int l = 0; l <= min(a[i], j); l++) {
        sum +=
            dp[i][j - l] * comb[n - j + l][l] % M * comb[n - l][a[i] - l] % M;
      }
      dp[i + 1][j] = sum % M;
    }
  }
  cout << dp[k][n] << endl;
}
