#include <bits/stdc++.h>
using namespace std;
int maxElement(int arr[], int n) {
  int maxi = arr[0];
  for (int i = 1; i < n; i++) {
    if (arr[i] > maxi) maxi = arr[i];
  }
  return maxi;
}
int minElement(int arr[], int n) {
  int mini = arr[0];
  for (int i = 1; i < n; i++) {
    if (arr[i] < mini) mini = arr[i];
  }
  return mini;
}
string trim(const string& str) {
  size_t first = str.find_first_not_of(' ');
  if (string::npos == first) {
    return str;
  }
  int last = str.find_last_not_of(' ');
  return str.substr(first, (last - first + 1));
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> arr(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> arr[i];
  long long int dp[n + 1][k + 1];
  dp[0][0] = 1;
  for (int i = 1; i < k + 1; i++) dp[0][i] = 0;
  for (int i = 1; i < n + 1; i++) dp[i][0] = 1;
  for (int i = 1; i < n + 1; i++) {
    long long int sum[k + 1];
    sum[0] = 1;
    for (int p = 1; p <= k; p++)
      sum[p] = ((sum[p - 1] % 1000000007) + (dp[i - 1][p] % 1000000007)) %
               1000000007;
    for (int p = 0; p <= k; p++) {
      if (p - arr[i] - 1 >= 0)
        dp[i][p] = sum[p] - sum[p - arr[i] - 1];
      else
        dp[i][p] = sum[p];
    }
  }
  cout << dp[n][k] << '\n';
  cerr << "Time elapsed" << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
  return 0;
}
