#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int base, long long int exp, long long int M) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % M;
    base = (base * base) % M;
    exp >>= 1;
  }
  return res;
}
const long long int M = 1e9 + 7;
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  vector<long long int> dp(k + 1);
  dp[0] = 1;
  for (long long int i = 0; i <= n - 1; ++i) {
    cin >> a[i];
    vector<long long int> cum(k + 1);
    for (long long int used = k; used >= 0; --used) {
      long long int val = dp[used];
      long long int l = used + 1;
      long long int r = used + min(a[i], k - used);
      if (l <= r) {
        cum[l] += val;
        cum[l] %= M;
        if (r + 1 <= k) {
          cum[r + 1] -= val;
          cum[r + 1] %= M;
        }
      }
    }
    long long int sum = 0;
    for (long long int i = 0; i <= k; ++i) {
      sum += cum[i];
      sum %= M;
      dp[i] += sum;
      dp[i] %= M;
    }
  }
  cout << dp[k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
