#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long mod = 1e9 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 2));
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      dp[i][j] += dp[i - 1][j];
      dp[i][j] %= mod;
      if (j + a[i - 1] <= k) {
        dp[i][j + a[i - 1] + 1] -= dp[i - 1][j];
        dp[i][j + a[i - 1] + 1] %= mod;
        dp[i][j + a[i - 1] + 1] %= mod;
      } else {
        dp[i][k + 1] -= dp[i - 1][j];
        dp[i][k + 1] += mod;
        dp[i][k + 1] %= mod;
      }
    }
    for (long long j = 0; j <= k; j++) {
      dp[i][j + 1] += dp[i][j];
      dp[i][j + 1] %= mod;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
