#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vpl = vector<pair<long long, long long>>;
using vs = vector<string>;
using pl = pair<long long, long long>;
using ll = long long int;
using vb = vector<bool>;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2> &p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
void printcase(ll &x) { cout << "Case #" << x << ": "; }
void read(vector<ll> &v, ll &n) {
  for (ll i = 0; i < n; ++i) cin >> v[i];
}
void read(ll &x) { cin >> x; }
void read(string &s) { cin >> s; }
void read(int &x) { cin >> x; }
void read(ll a[], ll &n) {
  for (ll i = 0; i < n; ++i) cin >> a[i];
}
void print() { cout << endl; }
void write(vector<ll> &v, ll &n) {
  for (ll i = 0; i < n; ++i) cout << v[i] << " ";
  cout << endl;
}
void write(vector<ll> &v) {
  ll n = v.size();
  for (ll i = 0; i < n; ++i) cout << v[i] << " ";
  cout << endl;
}
void write(ll x) { cout << x << endl; }
void write(string &s) { cout << s << endl; }
void write(int &x) { cout << x << endl; }
void write(ll a[], ll &n) {
  for (ll i = 0; i < n; ++i) cout << a[i] << " ";
  cout << endl;
}
const ll mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  ll n, k;
  cin >> n >> k;
  vl a(n + 1);
  for (ll i = 0; i < n; ++i) cin >> a[i + 1];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0));
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= k; i++) dp[0][k] = 0;
  vector<ll> pre(k + 1, 1);
  ll a1, b, m;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= k; j++) {
      m = min(a[i], j);
      a1 = j - m;
      b = j;
      if (a1 == 0)
        dp[i][j] += (pre[b] % mod);
      else
        dp[i][j] += ((pre[b] - pre[a1 - 1]) % mod);
      dp[i][j] = (dp[i][j] % mod);
    }
    pre[0] = dp[i][0];
    for (ll j = 1; j <= k; j++) {
      pre[j] = ((pre[j - 1] + dp[i][j]) % mod);
    }
  }
  cout << (dp[n][k] % mod) << endl;
  return 0;
}
