#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
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);
  vector<long long> accum(k + 2, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k + 1; j++) {
      accum[j] = (accum[j - 1] + dp[j - 1]) % MOD;
    }
    for (int j = k; j >= 0; j--) {
      int lb = max(0, j - a[i]);
      dp[j] = (accum[j + 1] - accum[lb]) % MOD;
    }
  }
  cout << dp[k] << endl;
  return 0;
}
