#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int INF = (1LL << 50);
const int N = 100005;
void add_self(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
void sub_self(int &a, int b) {
  a -= b;
  if (a < 0) a += mod;
}
int main() {
  cin.tie(NULL), cout.sync_with_stdio(true);
  int n, k;
  cin >> n >> k;
  vector<int> lim(n), dp(k + 1);
  for (int i = 0; i < n; i++) cin >> lim[i];
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int> pref(k + 1);
    for (int used = k; used >= 0; --used) {
      int value = dp[used];
      int l = used + 1;
      int r = used + min(lim[i], k - used);
      add_self(pref[l], value);
      if (r + 1 <= k) sub_self(pref[r + 1], value);
    }
    int sum = 0;
    for (int i = 0; i <= k; ++i) {
      add_self(sum, pref[i]);
      add_self(dp[i], sum);
    }
  }
  cout << dp[k] << '\n';
  return 0;
}
