#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int N, K;
vector<int> A;
vector<vector<int> > dp;
vector<int> sum;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  A.resize(N + 1);
  for (int i = 1; i <= N; ++i) cin >> A[i];
  dp.resize(N + 1, vector<int>(K + 1, 0));
  sum.resize(K + 2, 0);
  dp[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= K; ++j) sum[j + 1] = (sum[j] + dp[i - 1][j]) % MOD;
    for (int j = 0; j <= K; ++j)
      dp[i][j] = (sum[j + 1] - sum[max(0, j - A[i])] + MOD) % MOD;
  }
  int ans = dp[N][K];
  cout << ans << '\n';
  return 0;
}
