#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
const int MOD = 1e9 + 7;
void doc() {
  freopen("OB.inp", "r", stdin);
  freopen("OB.out", "w", stdout);
}
void solve() {
  int n, K;
  cin >> n >> K;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long f[n][K + 1], s[n][K + 1];
  memset(f, 0, sizeof(f));
  memset(s, 0, sizeof(s));
  for (int i = 0; i <= a[0]; i++) f[0][i] = 1;
  for (int i = 0; i < n; i++) s[i][0] = 1;
  for (int i = 1; i <= K; i++) {
    s[0][i] = (s[0][i - 1] + f[0][i]) % MOD;
  }
  for (int i = 1; i < n; i++)
    for (int j = 1; j <= K; j++) {
      if (j <= a[i])
        f[i][j] = s[i - 1][j] % MOD;
      else
        f[i][j] = (s[i - 1][j] - s[i - 1][j - a[i] - 1] + MOD) % MOD;
      s[i][j] = (s[i][j - 1] + f[i][j]) % MOD;
    }
  cout << f[n - 1][K];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
}
