#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void solve() {
  int i, j, m, n, k;
  cin >> n >> k;
  int arr[n + 1], dp[n + 1][k + 1], sum[k + 1];
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  dp[0][0] = sum[0] = 1;
  for (i = 1; i <= n; i++) {
    for (int m = 1; m <= k; m++) {
      sum[m] = sum[m - 1] + dp[i - 1][j];
    }
    for (j = 1; j <= k; j++) {
      if (j - arr[i] <= 0)
        dp[i][j] = sum[j];
      else
        dp[i][j] = sum[j] - sum[j - arr[i] - 1];
      if (dp[i][j] >= mod) dp[i][j] -= mod;
    }
  }
  cout << dp[n][k] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
