#include <bits/stdc++.h>
int upll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? -1
         : *(long long*)a > *(long long*)b ? 1
                                           : 0;
}
int downll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? 1
         : *(long long*)a > *(long long*)b ? -1
                                           : 0;
}
void sortup(long long* a, int n) { qsort(a, n, sizeof(long long), upll); }
void sortdown(long long* a, int n) { qsort(a, n, sizeof(long long), downll); }
long long pom(long long a, long long n, int m) {
  long long x = 1;
  for (a %= m; n; n /= 2) n& 1 ? x = x * a % m : 0, a = a * a % m;
  return x;
}
long long fact[100010];
long long invfact[100010];
void makefact(int n, long long m) {
  n = ((n) < (m - 1) ? (n) : (m - 1));
  fact[0] = 1;
  for (long long i = (0); i < (n); i++) fact[i + 1] = fact[i] * (i + 1) % m;
  invfact[n] = pom(fact[n], m - 2, m);
  for (int i = n; i > 0; i--) invfact[i - 1] = invfact[i] * i % m;
}
long long choose(int n, int r, int m) {
  return n < 0 || r < 0 || n - r < 0
             ? 0
             : fact[n] * invfact[r] % m * invfact[n - r] % m;
}
long long dp[30][1010];
int a[1010];
int main() {
  makefact(3000, 1000000007);
  int n, k;
  scanf("%d%d", &n, &k);
  for (long long i = (0); i < (n); i++) scanf("%d", a + i);
  dp[0][0] = 1;
  for (long long i = (1); i < (n + 1); i++)
    dp[0][0] = dp[0][0] * i % 1000000007;
  for (long long i = (0); i < (k); i++)
    for (long long j = (0); j < (n + 1); j++) {
      for (long long k = (0); k < (n - j + 1); k++)
        dp[i + 1][j + k] =
            (dp[i + 1][j + k] + dp[i][j] * choose(n - k, a[i] - k, 1000000007) %
                                    1000000007 * invfact[k]) %
            1000000007;
    }
  printf("%lld", dp[k][n]);
}
