#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int child = 1; child <= n; ++child) {
    int a;
    cin >> a;
    vector<int> pref(k + 1, 0);
    for (int j = k; j >= 0; --j) {
      int tmp = dp[j];
      int L = j + 1;
      int R = j + min(a, k - j);
      if (L <= R) {
        pref[L] += tmp;
        pref[L] %= mod;
        if (R + 1 <= k) {
          pref[R + 1] -= tmp;
          pref[R + 1] %= mod;
        }
      }
    }
    int pref_sum = 0;
    for (int i = 0; i <= k; ++i) {
      pref_sum += pref[i];
      pref_sum %= mod;
      dp[i] += pref_sum;
      dp[i] %= mod;
    }
  }
  cout << dp[k] << endl;
  return 0;
}
