#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  const int mod = 1e9 + 7;
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi dp(k + 1, 0);
  dp[0] = 1;
  vi pref(k + 1, 1);
  for (int i = 0; i < n; i++) {
    vi dp_new(k + 1, 0);
    for (int j = 0; j <= k; j++) {
      if (j - a[i] < 0) continue;
      int l = max(0, j - a[i]);
      dp_new[j] = pref[j] - (l ? pref[l - 1] : 0);
    }
    dp = dp_new;
    pref = dp;
    for (int i = 1; i <= k; i++) {
      (pref[i] += pref[i - 1]) %= mod;
    }
  }
  cout << dp.back();
}
