#include <bits/stdc++.h>
using namespace std;
template <class T>
using arr = vector<vector<T>>;
template <class T>
void pr(T x) {
  cout << x << endl;
}
template <class T>
void prvec(vector<T> &a) {
  for (int i = 0; i < (a.size() - 1); i++) {
    cout << a[i] << " ";
  }
  cout << a[a.size() - 1] << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void prarr(vector<vector<T>> &a) {
  for (int i = 0; i < (a.size()); i++) {
    for (int j = 0; j < (a[i].size()); j++) {
      cout << a[i][j];
      printf(" ");
    }
    printf("\n");
  }
  printf("\n");
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n + 1);
  a[0] = 0;
  for (int i = 0; i < (n); i++) cin >> a[i + 1];
  arr<long long> dp(n + 1, vector<long long>(k + 1));
  for (int i = 0; i < (n + 1); i++)
    for (int j = 0; j < (k + 1); j++) dp[i][j] = 0;
  for (int i = 0; i < (n + 1); i++) dp[i][0] = 1;
  for (int i = 1; i < (n + 1); i++) {
    for (int j = 1; j < (k + 1); j++) {
      dp[i][j] += (dp[i][j - 1] + dp[i - 1][j]) % (1000000007);
      if (j - a[i] - 1 >= 0) dp[i][j] -= dp[i][j - a[i] - 1];
      dp[i][j] %= (1000000007);
      if (dp[i][j] < 0) dp[i][j] += (1000000007);
    }
  }
  pr(dp[n][k]);
  return 0;
}
