#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> A;
  long long a;
  long long MOD = 1000000007;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }
  long long dp[N + 1][K + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    long long sum = 0;
    long long a = A[i];
    for (int k = 0; k <= K; ++k) {
      sum = (sum + dp[i][k]) % MOD;
      int m = k - a - 1;
      if (m >= 0) {
        sum = (sum - dp[i][m]) % MOD;
      }
      dp[i + 1][k] = sum;
    }
  }
  cout << dp[N][K] << endl;
  return 0;
}
