#include <bits/stdc++.h>
using namespace std;
template <class T>
void in(vector<T>& V) {
  for (auto itr = V.begin(); itr != V.end(); itr++) cin >> *itr;
  return;
}
template <class T>
void out(vector<T>& V) {
  for (T& itr : V) cout << itr << endl;
  return;
}
int N, K, MOD = 1e9 + 7;
vector<int> A;
int main() {
  cin >> N >> K;
  A.resize(N);
  in(A);
  vector<vector<long long>> DP;
  DP.resize(N, vector<long long>(K + 1, 0));
  for (int k = 0; k <= A[0]; k++) DP[0][k] = 1;
  for (int n = 1; n < N; n++) {
    DP[n][0] = 1;
    for (int k = 1; k <= A[n]; k++) {
      DP[n][k] = DP[n][k - 1] + DP[n - 1][k];
      DP[n][k] %= MOD;
    }
    for (int k = A[n] + 1; k <= K; k++) {
      DP[n][k] = DP[n][k - 1] + DP[n - 1][k] - DP[n - 1][k - A[n] - 1];
      DP[n][k] %= MOD;
    }
  }
  cout << DP[N - 1][K] << endl;
  return 0;
}
