#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int solve(long long int n, long long int k, long long int* arr) {
  long long int dp[n + 2][k + 2];
  for (long long int i = 0; i <= n; i++)
    for (long long int j = 0; j <= k; j++) dp[i][j] = 0;
  for (long long int i = 0; i <= k; i++) {
    dp[1][i] = (i > arr[1]) ? 0 : 1;
  }
  for (long long int i = 2; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] -
                    (j - arr[i] - 1 >= 0 ? dp[i - 1][j - arr[i] - 1] : 0)) %
                   1000000007;
    }
  }
  return dp[n][k];
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int arr[n + 1];
  long long int sum = 0;
  set<long long int> s;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += arr[i];
    s.insert(arr[i]);
  }
  cout << solve(n, k, arr) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
