#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int N = 1e5;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<long long>> dp(n + 5, vector<long long>(k + 5, 0));
  vector<vector<long long>> pref(n + 5, vector<long long>(k + 5, 0));
  long long a[n + 5];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i][0] = 1;
    pref[i][0] = 1;
    pref[0][i] = 1;
  }
  pref[0][0] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= k; j++) {
      dp[i][j] =
          (pref[i - 1][j] - pref[i - 1][max(j - a[i] - 1, 0ll)] + MOD) % MOD;
      pref[i][j] = (pref[i][j - 1] + dp[i][j]) % MOD;
    }
  }
  cout << dp[n][k];
  return 0;
}
