#include <bits/stdc++.h>
using namespace std;
int lim = 1e6;
long long inf = 1e9 + 7;
vector<long long> a;
int n;
vector<vector<long long> > dp;
long long solve(long long k, int i) {
  if (k < 0 or i >= n) {
    return 0;
  }
  if (k == 0) {
    return 1;
  } else if (i == n) {
    return 0;
  } else if (dp[k][i] != -1) {
    return dp[k][i];
  } else {
    cout << i << " " << k << " " << a[i] << endl;
    if (a[i] < k) {
      long long ans1 = solve(k - 1, i);
      long long ans2 =
          (solve(k, i + 1) - solve(k - 1 - a[i], i + 1) + 2 * inf) % inf;
      dp[k][i] = (ans1 + ans2) % inf;
    } else {
      long long ans1 = solve(k - 1, i);
      long long ans2 = solve(k, i + 1);
      dp[k][i] = (ans1 + ans2) % inf;
    }
    return dp[k][i];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long k;
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp.resize(k + 1, vector<long long>(n, -1));
  cout << solve(k, 0) << '\n';
  ;
}
