#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5, K = 25, mod = 1e9 + 7;
int a[N], f[K][N], c[N][N];
inline int _add(register int x, register int y) {
  return (x += y) >= mod ? x - mod : x;
}
int main() {
  register int n, k, i, j, x;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 0; i <= n; ++i) {
    c[i][0] = 1;
    for (j = 1; j <= i; ++j) c[i][j] = _add(c[i - 1][j], c[i - 1][j - 1]);
  }
  f[0][0] = 1;
  for (i = 1; i <= k; ++i)
    for (j = 0; j <= n; ++j)
      for (x = 0; x <= j && x <= a[i]; ++x)
        f[i][j] = (f[i][j] + (long long)f[i - 1][j - x] * c[n - (j - x)][x] %
                                 mod * c[n - x][a[i] - x]) %
                  mod;
  printf("%d\n", f[k][n]);
  return 0;
}
