#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 10;
long long dp[maxn][2], p[maxn][2];
long long get_sum(long long i, long long l) {
  if (i < 0) return 0;
  return p[i][l];
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long l = 0, r = 1;
  for (long long i = 0; i < n; i++) {
    long long first;
    cin >> first;
    if (i == 0) {
      for (long long j = 0; j <= first; j++) {
        dp[j][r] = 1;
      }
      for (long long j = 0; j <= k; j++) {
        p[j][r] = get_sum(j - 1, r) + dp[j][r];
      }
      swap(l, r);
      continue;
    }
    for (long long j = 0; j <= k; j++) {
      dp[j][r] = get_sum(j, l) - get_sum(j - first - 1, l);
      dp[j][r] %= mod;
      p[j][r] = get_sum(j - 1, r) + dp[j][r];
      p[j][r] %= mod;
    }
    swap(l, r);
  }
  cout << dp[k][l] << "\n";
  return 0;
}
