#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void add_self(int &a, int b) {
  a += b;
  if (a > mod) a -= mod;
}
void sub_self(int &a, int b) { a -= b; }
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int> fake(k + 1);
    for (int j = k; j >= 0; j--) {
      int tmp = dp[j];
      int lb = j + 1;
      int ub = j + min(k - j, arr[i]);
      if (lb <= ub) {
        add_self(fake[lb], tmp);
        if (ub + 1 <= k) sub_self(fake[ub + 1], tmp);
      }
    }
    int sm = 0;
    for (int x = 0; x <= k; x++) {
      add_self(sm, fake[x]);
      add_self(dp[x], sm);
    }
  }
  cout << dp[k] << endl;
}
