#include <bits/stdc++.h>
using namespace std;
int MAXNUM = 5e3 + 5;
vector<int> vis(MAXNUM);
vector<int> pr;
void sieve() {
  pr.push_back(2);
  for (long long i = 3; i < MAXNUM; i += 2)
    if (!vis[i]) {
      pr.push_back(i);
      for (long long j = i * i; j < MAXNUM; j += 2 * i) vis[j] = true;
    }
}
long long mod = 1000000007;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vector<vector<int>> dp(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    dp[i].resize(k + 1);
    dp[i][0] = 1;
  }
  dp[0][v[0]] = 1;
  for (int i = 1; i < n; i++) {
    vector<int> temp(k + 1);
    temp[0] = 1;
    for (int j = 1; j <= k; j++) {
      temp[j] = (temp[j - 1] + dp[i - 1][j]) % mod;
      if (v[i] < j) {
        dp[i][j] = (temp[j] - temp[j - v[i] - 1] + mod) % mod;
      } else {
        dp[i][j] = temp[j] % mod;
      }
    }
  }
  cout << dp[n - 1][k] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
