#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans *= a;
    p /= 2;
    a *= a;
    ans %= mod;
    a %= mod;
  }
  return ans;
}
long long mdinv(long long a) { return powmod(a, mod - 2); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<vector<long long> > dp(n, vector<long long>(k + 1)),
      cu(n, vector<long long>(k + 1));
  for (int i = 0; i <= k; i++) {
    if (i <= v[0]) dp[0][i] = 1;
    if (i <= v[0]) cu[0][i] = 1;
    if (i > 0) cu[0][i] += cu[0][i - 1];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = cu[i - 1][j];
      if (j - v[i] - 1 >= 0) {
        dp[i][j] -= cu[i - 1][j - v[i] - 1];
      }
      if (i == n - 1 && j == k) {
        cerr << "dp[i][j]"
             << ": " << dp[i][j] << endl;
      }
      dp[i][j] += mod;
      if (i == n - 1 && j == k) {
        cerr << "dp[i][j]"
             << ": " << dp[i][j] << endl;
      }
      dp[i][i] = dp[i][j] % mod;
      dp[i][j] = dp[i][j] % mod;
      cu[i][j] = dp[i][j];
      if (j > 0) {
        cu[i][j] += cu[i][j - 1];
      }
      cu[i][j] %= mod;
    }
  }
  cout << dp[n - 1][k] << endl;
  return 0;
}
