#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<vector<long long>> dp(N + 1, vector<long long>(K + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i < N + 1; i++) {
    vector<long long> sum(N, 0);
    sum[0] = dp[i - 1][0];
    for (int j = 0; j < K; j++) {
      sum[j + 1] = sum[j] + dp[i - 1][j + 1] % MOD;
    }
    for (int j = 0; j < K + 1; j++) {
      int kmin = max(j - a[i - 1], 0);
      dp[i][j] = (MOD + sum[j] - (kmin ? sum[kmin - 1] : 0)) % MOD;
    }
  }
  cout << dp[N][K] << endl;
}
