#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> dp(k + 2);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<int> nxt(k + 2);
    for (int j = 0; j <= a[i]; ++j) {
      const int l = j, r = min(j + a[i] + 1, k + 1);
      (nxt[l] += dp[j]) %= mod;
      (nxt[r] -= dp[j]) %= mod;
    }
    for (int j = 0; j <= k; ++j) {
      (nxt[j + 1] += nxt[j]) %= mod;
    }
    dp = move(nxt);
  }
  cout << dp[k] << endl;
}
