#include <bits/stdc++.h>
using namespace std;
void solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long maxi = -1;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    maxi = max(a[i], maxi);
  }
  vector<vector<long long> > dp(n, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  for (long long i = 1; i <= min(a[0], k); i++) {
    dp[0][i] = 1;
  }
  if (n == 1) {
    cout << dp[0][k] << '\n';
    return 0;
  }
  for (long long i = 1; i <= k; i++) {
    dp[0][i] += dp[0][i - 1];
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = 1;
      } else {
        long long l = max(j - a[i], (long long)0);
        if (l > 0)
          dp[i][j] = (dp[i - 1][j] - dp[i - 1][l - 1]) % 1000000007;
        else {
          dp[i][j] = dp[i - 1][j];
        }
      }
    }
    if (i == (n - 1)) break;
    for (long long j = 1; j <= k; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i][j]) % 1000000007;
    }
  }
  cout << dp[n - 1][k] << '\n';
}
