#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> a;
vector<vector<int>> dp;
vector<int> pref_sum;
const int MOD = 1e9 + 7;
int main() {
  cin >> N >> K;
  a.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  dp.resize(N, vector<int>(K + 1));
  for (int i = 0; i <= a[0]; ++i) {
    dp[0][i] = 1;
  }
  pref_sum.resize(K + 2);
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j <= K; ++j) {
      pref_sum[j + 1] = (pref_sum[j] + dp[i - 1][j]) % MOD;
      dp[i][j] = (pref_sum[j + 1] - pref_sum[j - min(j, a[i])]) % MOD;
    }
  }
  cout << (dp[N - 1][K] < 0) ? dp[N - 1][K] + MOD : dp[N - 1][K];
}
