#include <bits/stdc++.h>
using namespace std;
int nCrModp(int n, int r, int p) {
  if (r > n - r) r = n - r;
  int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
void func() {
  long long n, k;
  cin >> n >> k;
  long long ans = nCrModp((n + k - 1), k, 1000000007), arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == k) {
      continue;
    } else
      sum += nCrModp((n + k - 2 - arr[i]), k - 1 - arr[i], 1000000007);
  }
  cout << (ans - sum) % 1000000007 << "\n";
}
int main() {
  int t = 1, cnt = 0;
  while (t--) {
    func();
  }
}
