#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long>> dp(n, vector<long long>(k + 1, 0));
  for (long long i = 0; i < n; i++) {
    if (i == 0) {
      for (long long j = 0; j <= a[i]; j++) dp[i][j] = 1;
    } else {
      queue<long long> data;
      long long now = 0;
      for (long long j = 0; j <= k; j++) {
        data.push(dp[i - 1][j]);
        now += dp[i - 1][j];
        now %= mod;
        if (j > a[i]) {
          data.pop();
          now -= data.front();
          now %= mod;
          now += mod;
          now %= mod;
        }
        dp[i][j] = now;
      }
    }
  }
  cout << dp[n - 1][k] << endl;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long t = 1;
  while (t > 0) {
    t--;
    solve();
  }
  return 0;
}
