#include <bits/stdc++.h>
using namespace std;
void print_err() { cerr << "\n"; }
template <class T, class... Arg>
void print_err(T x, Arg&&... args) {
  cerr << x << " ";
  print_err(args...);
}
void solve() {
  int n, k, i, j, x, l;
  long long ans;
  vector<int> A;
  cin >> n;
  cin >> k;
  A.push_back(0);
  for (i = 0; i < n; i++) {
    cin >> x;
    A.push_back(x);
  }
  long long dp[n + 1][k + 1];
  for (i = 0; i < k + 1; i++) {
    dp[0][i] = 1;
  }
  for (i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  for (i = 1; i < n; i++) {
    for (j = 1; j < k + 1; j++) {
      ans = 0;
      if (j - A[i] > 0) {
        ans = dp[i - 1][j] - dp[i - 1][j - A[i] - 1];
      } else {
        ans = dp[i - 1][j];
      }
      dp[i][j] = ans + dp[i][j - 1];
    }
  }
  ans = 0;
  if (k - A[n] > 0) {
    ans = dp[n - 1][k] - dp[n - 1][k - A[n] - 1];
  } else {
    ans = dp[n - 1][k];
  }
  cout << ans % 1000000007;
  cout << "\n";
}
int main() {
  solve();
  return 0;
}
