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