#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
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 < 0) a += mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1);
  dp[0] = 1;
  while (n--) {
    int limit;
    cin >> limit;
    vector<int> cur(k + 1, 0);
    for (int used = k; used >= 0; --used) {
      int L = used + 1;
      int R = used + min(limit, k - used);
      if (R < L) continue;
      add_self(cur[L], dp[used]);
      if (R + 1 <= k) sub_self(dp[R + 1], dp[used]);
    }
    int pre = 0;
    for (int i = 0; i <= k; ++i) {
      add_self(pre, cur[i]);
      add_self(dp[i], pre);
    }
  }
  cout << dp[k] << endl;
}
