#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    vector<ll> sum(k + 2);
    for (int j = 0; j < (k + 1); j++)
      sum[j + 1] = (sum[j] + dp[i - 1][j]) % MOD;
    for (int j = 0; j < (k + 1); j++)
      dp[i][j] = (sum[j + 1] - sum[max(0, j - a[i - 1])]) % MOD;
  }
  cout << dp[n][k] << endl;
  return 0;
}
