#include <bits/stdc++.h>
using ll = long long;
using namespace std;
constexpr int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = (1); i < (n + 1); i++) cin >> a[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0));
  vector<vector<ll>> sum(n + 1, vector<ll>(k + 2, 0));
  dp[0][0] = 1;
  sum[0][0] = 1;
  for (int i = (1); i < (n + 1); i++) {
    sum[i - 1][0] = 0;
    for (int j = (0); j < (k + 1); j++)
      sum[i - 1][j + 1] = (dp[i - 1][j] + sum[i - 1][j]) % mod;
    for (int j = (0); j < (k + 1); j++) {
      int l = max(0, j - a[i]), r = j + 1;
      dp[i][j] = sum[i - 1][r] - sum[i - 1][l];
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
