#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  ;
  long long m = 1e9 + 7;
  vector<vector<long long> > dp(n, vector<long long>(k + 1, 0));
  for (long long i = 0; i <= min(k, a[0]); i++) dp[0][i] = 1;
  long long z = 1;
  for (long long i = 1; i < n; i++) {
    vector<long long> sum(k + 1, 0);
    sum[0] = dp[i - 1][0];
    for (long long j = 1; j <= k; j++)
      sum[j] = (sum[j - 1] % m + dp[i - 1][j] % m) % m;
    for (long long j = 0; j <= k; j++) {
      long long l = j - min(j, a[i]) - 1;
      dp[i][j] = sum[j];
      if (l >= 0) dp[i][j] -= sum[l];
    }
  }
  cout << dp[n - 1][k] << "\n";
  return 0;
}
