#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[ ";
  for (auto e : v) os << e << " ";
  return os << "]";
}
template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
  os << "{ ";
  for (auto e : v) os << e << " ";
  return os << "}";
}
template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
  os << "{ ";
  for (auto e : v) os << e << " ";
  return os << "}";
}
template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
  return os << "( " << x.first << ", " << x.second << " )";
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& e : v) is >> e;
  return is;
}
template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
  return is >> x.first >> x.second;
}
void solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  cin >> a;
  vector<vector<ll>> dp(2, vector<ll>(k + 1, 0));
  const ll MOD = 1e9 + 7;
  for (int i = 0; i < n; ++i) {
    dp[i & 1][0] = 1;
    for (int t = 1; t <= a[i]; ++t) {
      dp[i & 1][t] = (dp[i & 1][t - 1] + dp[i & 1 ^ 1][t]) % MOD;
    }
    for (int t = a[i] + 1; t <= k; ++t) {
      if (i == 0)
        dp[i & 1][t] = 0;
      else {
        dp[i & 1][t] = dp[i & 1][t - 1];
        dp[i & 1][t] -= dp[i & 1 ^ 1][t - a[i] - 1];
        dp[i & 1][t] %= MOD;
        dp[i & 1][t] += dp[i & 1 ^ 1][t];
        dp[i & 1][t] %= MOD;
      }
    }
    if (0) cout << "dp[" << i << "] " << dp[i & 1] << "\n";
  }
  cout << dp[(n - 1) & 1][k] << "\n";
}
