#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  vector<long long> dp(K + 1);
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> A[i];
  }
  for (long long i = 0; i < (long long)(K + 1); i++) {
    dp[i] = 0ll;
  }
  dp[0] = 1ll;
  for (long long i = 0; i < (long long)(N); i++) {
    long long x[K + 1], y[K + 1];
    for (long long j = 0; j < (long long)(K + 1); j++) {
      x[j] = 0ll;
      y[j] = 0ll;
    }
    long long p = A[i];
    for (long long j = 0; j < (long long)(K + 1); j++) {
      x[j] += dp[j];
      if (j + p + 1 <= K) {
        x[j + p + 1] -= dp[j];
      }
    }
    y[0] = x[0];
    for (long long j = 0; j < (long long)(K); j++) {
      y[j + 1] = y[j] + x[j + 1];
      y[j + 1] %= (long long)1000000007;
    }
    for (long long j = 0; j < (long long)(K + 1); j++) {
      dp[j] = y[j];
      dp[j] %= (long long)1000000007;
    }
  }
  cout << dp[K];
}
