#include <bits/stdc++.h>
using namespace std;
long long fact[1000006], inv[1000006];
long long fp(long long base, long long exp) {
  if (exp == 0) return 1;
  long long ans = fp(base, exp / 2);
  ans = (ans * ans) % 1000000007;
  if (exp % 2 != 0) ans = (ans * (base % 1000000007)) % 1000000007;
  return ans;
}
void calcFacAndInv(long long n) {
  fact[0] = inv[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]) % 1000000007;
    inv[i] = fp(fact[i], 1000000007 - 2);
  }
}
long long ncr(long long n, long long r) {
  return ((fact[n] * inv[r]) % 1000000007 * inv[n - r]) % 1000000007;
}
long long npr(long long n, long long r) {
  return (fact[n] * inv[n - r]) % 1000000007;
}
int main() {
  calcFacAndInv(1000000);
  int n, k;
  cin >> n >> k;
  int arr[1000];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long lol = ncr((k + n - 1), k);
  for (int i = 0; i < n; i++) {
    long long koko = (k - arr[i]) * (1 + k - arr[i]) / 2;
    lol = (lol - koko + 1000000007) % 1000000007;
  }
  cout << lol;
  return 0;
}
