#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
ll pwr(ll a, ll b);
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 n, k;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int up_to;
    cin >> up_to;
    vector<int> helper(k + 1);
    for (int used = k; used >= 0; --used) {
      int L = used + 1;
      int R = used + min(up_to, k - used);
      add_self(helper[L], dp[used]);
      if (R + 1 <= k) sub_self(helper[R + 1], dp[used]);
    }
    int prefix_sum = 0;
    for (int i = 0; i <= k; i++) {
      add_self(prefix_sum, helper[i]);
      add_self(dp[i], prefix_sum);
    }
  }
  cout << dp[k] << "\n";
}
ll pwr(ll a, ll b) {
  a %= mod;
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
