#include <bits/stdc++.h>
using namespace std;
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<vector<int>> DP(N, vector<int>(K + 1));
  DP[0][0] = 1;
  for (int i = 1; i <= A[0]; i++) {
    DP[0][i] = DP[0][i - 1] + 1;
    DP[0][i] %= MOD;
  }
  for (int i = A[0] + 1; i <= K; i++) {
    DP[0][i] = DP[0][i - 1];
  }
  for (int i = 1; i < N; i++) {
    for (int j = 0; j <= K; j++) {
      if (j == 0) {
        DP[i][j] = DP[i - 1][j];
        continue;
      }
      if (j - A[i] - 1 < 0) {
        DP[i][j] = DP[i - 1][j];
      } else {
        DP[i][j] = DP[i - 1][j] - DP[i - 1][j - A[i] - 1];
      }
      DP[i][j] %= MOD;
      DP[i][j] += DP[i][j - 1];
      DP[i][j] %= MOD;
    }
  }
  cout << DP[N - 1][K] - DP[N - 1][K - 1];
  return 0;
}
