#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 6031)
using namespace std;
const long long mod = 1000000007;
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void add_self(T& a, T b) {
  a += b;
  if (a > mod) a -= mod;
}
template <typename T>
void sub_self(T& a, T b) {
  a -= b;
  if (a < 0) a += mod;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << setprecision(18) << fixed;
  int n, k;
  cin >> n >> k;
  vector<long long> dp(k + 1, 0);
  dp[0] = 1;
  for (int child = 0; child < n; child++) {
    int up_to;
    cin >> up_to;
    vector<long long> fake(k + 1);
    for (int used = k; used >= 0; used--) {
      long long tmp = dp[used];
      long long left = used + 1LL;
      long long right = min((long long)up_to, k - (long long)used) + used;
      if (left <= right) {
        add_self(fake[left], tmp);
        if (right < (int)(fake).size() - 1) sub_self(fake[right + 1], tmp);
      }
    }
    long long cur_sum = 0;
    for (int i = 0; i < (int)(fake).size(); i++) {
      add_self(cur_sum, fake[i]);
      add_self(dp[i], cur_sum);
    }
  }
  cout << dp[k];
  return 0;
}
