#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
const long long MOD = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1));
  vector<vector<long long>> pref(n + 1, vector<long long>(k + 1));
  for (long long i = 0; i <= n; i++) dp[i][0] = pref[i][0] = 1;
  for (long long j = 0; j <= k; j++) pref[0][j] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= k; j++) {
      if (j - a[i] - 1 >= 0) {
        dp[i][j] =
            (dp[i][j] + pref[i - 1][j] - pref[i - 1][j - a[i] - 1]) % MOD;
      } else {
        dp[i][j] = (dp[i][j] + pref[i - 1][j]) % MOD;
      }
      pref[i][j] = (pref[i][j] + dp[i][j] + pref[i][j - 1]) % MOD;
    }
  }
  cout << dp[n][k] << endl;
}
