#include <bits/stdc++.h>
using namespace std;
long long int dfs(int i, long long int *arr, long long int k, long long int n,
                  long long int **dp) {
  long long int *prefc = new long long int[k + 1]();
  long long int *pref = new long long int[k + 1]();
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  prefc[0] = 1;
  pref[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      if (i != 1) {
        if (j - arr[i - 1] - 1 < 0)
          dp[i][j] = prefc[j];
        else
          dp[i][j] =
              (prefc[j] % 1000000007 - prefc[j - arr[i - 1] - 1] % 1000000007) %
              1000000007;
      } else if (j <= arr[i - 1])
        dp[i][j] = 1;
      pref[j] = (pref[j - 1] % 1000000007 + dp[i][j] % 1000000007) % 1000000007;
    }
    prefc = pref;
    pref = new long long int[k + 1]();
    pref[0] = 1;
  }
  return dp[n][k] % 1000000007;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int *arr = new long long int[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long int **dp = new long long int *[n + 1];
  for (int i = 0; i <= n; i++) {
    dp[i] = new long long int[k + 1];
    for (int j = 0; j <= k; j++) dp[i][j] = 0;
  }
  cout << dfs(0, arr, k, n, dp) % 1000000007;
}
