#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
const int MOD = 1e9 + 7;
const int N = int(3e5) + 999;
int n, k;
void add(int &a, int b) {
  a = a + b;
  if (a >= MOD) a -= MOD;
}
void sub(int &a, int b) {
  a = a - b;
  if (a < 0) a += MOD;
}
int main() {
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int lmt;
    cin >> lmt;
    for (int used = k; used >= 0; used--) {
      int tmp = dp[used];
      vector<int> fake(k + 1, 0);
      int l = used + 1;
      int r = used + min(lmt, k - used);
      if (l <= r) {
        add(fake[l], tmp);
        if (r + 1 <= k) sub(fake[r + 1], tmp);
      }
      int pp = 0;
      for (int i = 0; i <= k; i++) {
        add(pp, fake[i]);
        add(dp[i], pp);
      }
    }
  }
  cout << dp[k];
  return 0;
}
