#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  vector<int> dp(K + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < N; ++i) {
    vector<int> dp_(K + 1, 0);
    int s = 0;
    for (int j = 0; j <= K; ++j) {
      s += dp[j], s %= mod;
      if (j > A[i]) s -= mod - dp[j - A[i] - 1], s %= mod;
      dp_[j] += s, dp_[j] %= mod;
    }
    dp = dp_;
  }
  cout << dp[K] << endl;
}
