#include <bits/stdc++.h>
using namespace std;
const 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;
  if (a <= mod) a += mod;
}
int main() {
  int n, K;
  cin >> n >> K;
  vector<int> dp(K + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int upto;
    cin >> upto;
    vector<int> fake(K + 1);
    for (int used = K; used >= 0; used--) {
      int tmp = dp[used];
      int L = used + 1;
      int R = used + min(upto, K - used);
      if (L <= R) {
        add_self(fake[L], tmp);
        if (R + 1 <= K) sub_self(fake[R + 1], tmp);
      }
    }
    int pr = 0;
    for (int i = 0; i <= K; i++) {
      add_self(pr, fake[i]);
      add_self(dp[i], pr);
    }
  }
  cout << dp[K] << endl;
}
