#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  long long dp[n + 1][k + 1];
  vector<long long> psa(n + 1, 0);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    psa[i] = a[i] + psa[i - 1];
  }
  vector<long long> ps[n + 4];
  for (long long i = 0; i <= n; i++) {
    ps[i].resize(k + 4);
    for (long long j = 0; j <= k; j++) ps[i][j] = 0;
  }
  for (long long i = 0; i <= k; i++) {
    if (i <= a[1])
      dp[1][i] = 1;
    else
      dp[1][i] = 0;
    ps[1][i + 1] = (ps[1][i] % ((long long)(1e9 + 7)) +
                    dp[1][i] % ((long long)(1e9 + 7))) %
                   ((long long)(1e9 + 7));
  }
  for (long long i = 2; i <= n; i++) {
    dp[i][0] = 1;
    ps[i][1] = 1;
    for (long long j = 1; j <= k; j++) {
      dp[i][j] = 0;
      dp[i][j] = (ps[i - 1][j + 1] % ((long long)(1e9 + 7)) -
                  ps[i - 1][max(0LL, j - a[i])] % ((long long)(1e9 + 7))) %
                 ((long long)(1e9 + 7));
      ps[i][j + 1] = (ps[i][j] % ((long long)(1e9 + 7)) +
                      dp[i][j] % ((long long)(1e9 + 7))) %
                     ((long long)(1e9 + 7));
    }
  }
  cout << dp[n][k] << endl;
}
