#include <bits/stdc++.h>
using namespace std;
void solve();
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long n;
long long calc(long long a[], long long i, long long k,
               vector<vector<long long>> &dp, vector<long long> &suf) {
  if (k == 0) return 1;
  if (i == n) return 0;
  if (dp[i][k] != -1) return dp[i][k];
  long long ans = 0;
  for (int j = 0; j <= a[i]; j++) {
    if (k - j >= 0 && (suf[i] - a[i] >= (k - j)))
      ans = (ans + calc(a, i + 1, k - j, dp, suf)) % 1000000007;
  }
  return dp[i][k] = ans;
}
void solve() {
  long long k, i, ans;
  cin >> n >> k;
  long long a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  vector<long long> suf(n);
  suf[n - 1] = a[n - 1];
  for (i = n - 2; i >= 0; i--) suf[i] = suf[i + 1] + a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, -1));
  ans = calc(a, 0, k, dp, suf);
  cout << ans << "\n";
}
