#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, k, *x, **dp;
  const int MOD = 1e9 + 7;
  cin >> n >> k;
  x = new int[n];
  dp = new int *[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    dp[i] = new int[k + 1];
    dp[i][0] = 1;
  }
  dp[n] = new int[k + 1];
  for (int i = 0; i <= k; i++) dp[n][i] = 1;
  for (int i = n - 1; i >= 0; i--)
    for (int rem = 1; rem <= k; rem++) {
      int &ret = dp[i][rem];
      ret = dp[i][rem - 1];
      if (x[i] < rem)
        ret += ((dp[i + 1][rem] - dp[i + 1][rem - x[i] - 1]) % MOD + MOD) % MOD;
      else
        ret += dp[i + 1][rem];
      if (ret >= MOD) ret -= MOD;
    }
  cout << dp[0][k] - dp[0][k - 1];
}
