#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  long long mod = 1e9 + 7;
  long long ans[n + 1][k + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) ans[i][j] = 0;
  }
  for (int i = 0; i <= n; i++) ans[i][0] = 1;
  long long pre[k + 1];
  for (int i = 0; i <= k; i++) pre[i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (A[i - 1] >= j)
        ans[i][j] = pre[j];
      else
        ans[i][j] = (pre[j] - pre[j - A[i - 1] - 1]);
    }
    for (int j = 0; j <= k; j++) pre[j] = ans[i][j];
    for (int j = 1; j <= k; j++) {
      pre[j] = pre[j] + pre[j - 1];
      pre[j] = pre[j] % mod;
    }
  }
  cout << ans[n][k];
  return 0;
}
