#include <bits/stdc++.h>
using namespace std;
int dp[101][100001], arr[101], pref[101][100001];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int N, K, M = 1e9 + 7;
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> arr[i];
  for (int i = 1; i <= N; i++) {
    for (int k = 0; k <= min(arr[i], K); k++) {
      dp[i][k] = pref[i][k] = (i == 1 ? 1 : pref[i - 1][k]);
      if (k) pref[i][k] += pref[i][k - 1];
      if (pref[i][k] >= M) pref[i][k] -= M;
    }
    for (int k = arr[i] + 1; k <= K; k++)
      dp[i][k] = pref[i - 1][arr[i]], pref[i][k] = pref[i][k - 1];
  }
  cout << dp[N][K] << "\n";
}
