#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
const LL MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(NULL);
  int N, K;
  cin >> N >> K;
  VI A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  VVLL dp(N + 1, VLL(K + 2, 0));
  for (int k = 1; k < K + 2; k++) dp[0][k] = 1;
  for (int i = 1; i <= N; i++)
    for (int k = 1; k < K + 2; k++) {
      int start = k, end = max(0, k - A[i - 1] - 1);
      dp[i][k] = dp[i][k - 1] + dp[i - 1][start] - dp[i - 1][end];
      dp[i][k] %= MOD;
    }
  cout << dp[N][K + 1] - dp[N][K] << endl;
  return 0;
}
