#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long N, K;
  cin >> N >> K;
  long long arr[N];
  for (long long i = 0; i < N; ++i) cin >> arr[i];
  long long dp[N + 1][K + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (long long i = 1; i <= N; ++i) {
    long long pre[K + 1];
    for (long long k = 0; k <= K; ++k) {
      pre[k] = (((k > 0) ? pre[k - 1] : 0) + dp[i - 1][k]) % 1000000007;
    }
    for (long long k = 0; k <= K; ++k)
      dp[i][k] = (pre[k] - ((k > arr[i - 1]) ? pre[k - arr[i - 1] - 1] : 0)) %
                 1000000007;
  }
  cout << dp[N][K] << endl;
}
