#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> dp(k + 1, 0);
  dp[k] = 1;
  for (int i = 0; i < n; i++) {
    vector<long long> rui(k + 1, 0);
    for (int j = 0; j <= k; j++) {
      rui[j] += dp[j];
      if (j - a[i] > 0) rui[j - a[i] - 1] -= dp[j];
    }
    dp[k] = rui[k];
    for (int j = k - 1; j >= 0; j--) {
      rui[j] = (rui[j] + rui[j + 1]) % 1000000007;
      dp[j] = rui[j];
    }
  }
  cout << dp[0] << endl;
  return 0;
}
