#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 + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= K; j++) {
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
      if (j - A[i - 1] - 1 >= 0) dp[i][j] -= dp[i - 1][j - A[i - 1] - 1];
    }
  }
  cout << dp[N][K] << endl;
  return 0;
}
