#include <bits/stdc++.h>
using namespace std;
long long M = (long long)(1e9 + 7);
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long dp[n + 1][k + 1];
  for (long long i = 0; i < k + 1; i++)
    if (i <= a[0])
      dp[1][i] = 1;
    else
      dp[1][i] = 0;
  for (long long i = 2; i < n + 1; i++) dp[i][0] = 1;
  for (long long i = 2; i < n + 1; i++) {
    long long to_add = dp[i - 1][0];
    for (long long j = 1; j < k + 1; j++) {
      if (j <= a[i - 1]) {
        to_add += (dp[i - 1][j]);
        to_add %= M;
        dp[i][j] = to_add;
      } else {
        to_add += (dp[i - 1][j] - dp[i - 1][j - a[i - 1] - 1]);
        to_add %= M;
        dp[i][j] = to_add;
      }
    }
  }
  cout << dp[n][k];
}
int main() {
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
