#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  int N, K, current, solution, temp1, temp2;
  cin >> N >> K;
  int arr[N];
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  if (K == 0) {
    cout << 1 << endl;
    return 0;
  }
  int dptable[N + 1][K + 1];
  for (int i = 0; i < N + 1; i++) {
    dptable[i][0] = 1;
  }
  for (int i = 0; i < K + 1; i++) {
    dptable[0][i] = 1;
  }
  for (int i = 1; i < N + 1; i++) {
    current = arr[i - 1];
    for (int j = 1; j < K + 1; j++) {
      if (j - current <= 0) {
        solution = dptable[i - 1][j];
      } else {
        temp1 = dptable[i - 1][j];
        temp2 = dptable[i - 1][j - current - 1];
        solution = ((temp1 % MOD) - (temp2 % MOD)) % MOD;
      }
      dptable[i][j] = ((solution % MOD) + (dptable[i][j - 1] % MOD)) % MOD;
    }
  }
  solution = (dptable[N][K] % MOD - dptable[N][K - 1] % MOD) % MOD;
  cout << solution << endl;
  return 0;
}
