#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, 1, -1};
template <typename T>
T GCD(T u, T v) {
  return v ? GCD(v, u % v) : u;
}
int main() {
  ll N, K;
  cin >> N >> K;
  ll a[N];
  ll sum = 0;
  ll b[100010], imos[100010];
  fill(b, b + 100001, 0);
  fill(imos, imos + 100001, 0);
  b[0] = N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    b[a[i]]++;
    sum += a[i];
  }
  if (sum < K) {
    cout << 0 << endl;
    return 0;
  } else if (sum == K) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 0;
  ll cnt = N;
  for (ll i = 1; i <= sum - K; i++) {
    ans += cnt;
    if (ans >= 1000000000 + 7) ans -= 1000000000 + 7;
    cnt -= b[i];
  }
  cout << ans << endl;
}
