#include <bits/stdc++.h>
using namespace std;
void add(int& a, int b) {
  a += b;
  if (a > 1e9 + 7) a -= 1e9 + 7;
}
void sub(int& a, int b) {
  a -= b;
  if (a < 0) a += 1e9 + 7;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    long long maxVal;
    cin >> maxVal;
    vector<int> store(k + 1, 0);
    for (int usedTillNow = k; usedTillNow >= 0; --usedTillNow) {
      int upperLimit = usedTillNow + min(k - usedTillNow, maxVal);
      int lowerLimit = usedTillNow + 1;
      int temp = dp[usedTillNow];
      if (lowerLimit <= upperLimit) add(store[lowerLimit], temp);
      if (upperLimit <= k - 1) sub(store[upperLimit + 1], temp);
    }
    int prefix = 0;
    for (int j = 0; j <= k; ++j) {
      add(prefix, store[j]);
      add(dp[j], prefix);
    }
  }
  cout << dp[k] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1, t1 = 1;
  while (t--) {
    solve();
  }
  return 0;
}
