#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
signed main() {
  long long N, K;
  cin >> N >> K;
  vector<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 < N + 1; i++) {
    for (long long j = 0; j < K + 1; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (long long i = 1; i < N + 1; i++) {
    vector<long long> cs(K + 2);
    for (long long k = 0; k < K + 1; k++) {
      cs[k + 1] = (cs[k] + dp[i - 1][k]) % mod;
    }
    for (long long j = 0; j < K + 1; j++) {
      dp[i][j] = (cs[j + 1] - cs[max(j - A[i - 1], 0LL)]) % mod;
    }
  }
  cout << dp[N][K] << endl;
}
