#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1 * INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1 * LLINF;
template <class Ch, class Tr, class Container>
basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os,
                                  Container const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <class X, class Y>
ostream& operator<<(ostream& os, pair<X, Y> const& p) {
  return os << "[ " << p.first << ", " << p.second << "]";
}
const int MOD = 1e9 + 7;
int madd(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int msub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> A = vector<int>();
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    A.push_back(x);
  }
  vector<vector<long long> > dp =
      vector<vector<long long> >(n, vector<long long>(k + 1, 0));
  for (int c = 0; c <= A[0]; c++) {
    dp[0][c] = 1;
  }
  vector<long long> P = vector<long long>(k + 1, 0);
  P[0] = dp[0][0];
  P[0] %= MOD;
  for (int c = 1; c <= k; c++) {
    P[c] = madd(dp[0][c], P[c - 1]);
  }
  for (int r = 1; r < n; r++) {
    vector<long long> NP = vector<long long>(k + 1, 0);
    for (int c = 0; c <= k; c++) {
      int cutoff = c - A[r] - 1;
      dp[r][c] = madd(P[c], (cutoff >= 0 ? P[cutoff] : 0));
    }
    for (int c = 0; c <= k; c++) {
      NP[c] = madd(dp[r][c], (c > 0 ? NP[c - 1] : 0));
    }
    P = NP;
  }
  cout << dp[n - 1][k] % MOD;
}
