#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll M = 1000000007;
const ll N = 998244353;
ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll inv(ll x, ll m) { return power(x, m - 2, m); }
ll nCr(ll n, ll r) {
  if (r == 0) return 1;
  vector<ll> fac(n);
  return (fac[n] * inv(fac[r], M) % M * inv(fac[n - r], M) % M) % M;
}
struct comp {
  template <typename T>
  bool operator()(const T &a, const T &b) {
    if (a.first == b.first)
      return (a.second < b.second);
    else
      return (a.first < b.first);
  }
};
bool mod(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.first != b.first)
    return (a.first > b.first);
  else
    return (a.second > b.second);
}
void sieve() {
  vector<bool> pr(1000000 + 1, 1);
  for (ll i = 2; i * i <= 1000000; i++)
    if (pr[i] == 1)
      for (ll j = i * i; j <= 1000000; j += i) pr[j] = 0;
}
bool isValid(ll i, ll j, ll n, ll m) {
  if (i >= 0 && i < n && j >= 0 && j < m) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, m, i, j, k, num, num1, num2, flag = 0;
  cin >> n >> k;
  vector<ll> v(n);
  for (i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<ll> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<ll> fake(k + 1);
    for (int j = k; j >= 0; j--) {
      ll tmp = dp[j];
      ll L = j + 1;
      ll R = j + min(k - j, v[i]);
      if (L <= R) {
        fake[L] = (fake[L] + tmp) % M;
        if (R + 1 <= k) {
          fake[R + 1] = (fake[R + 1] - tmp) % M;
        }
      }
    }
    ll sum = 0;
    for (j = 0; j <= k; j++) {
      sum = (sum + fake[j]) % M;
      dp[j] = (dp[j] + sum) % M;
    }
  }
  cout << dp[k] << "\n";
  return 0;
}
