#include <bits/stdc++.h>
const long long mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i < (long long)(n + 1); ++i) {
    cin >> a[i];
  }
  long long d[n + 1][k + 1];
  long long p[n + 1][k + 1];
  memset(d, 0, sizeof(long long) * (n + 1) * (k + 1));
  memset(p, 0, sizeof(long long) * (n + 1) * (k + 1));
  for (long long i = 0; i < (long long)(a[1] + 1); ++i) {
    d[1][i] = 1;
  }
  p[1][0] = d[1][0];
  for (long long i = 1; i < (long long)(k + 1); ++i) {
    p[1][i] = (p[1][i - 1] + d[1][i]) % mod;
  }
  for (long long i = 2; i < (long long)(n + 1); ++i) {
    for (long long j = 0; j < (long long)(k + 1); ++j) {
      if (j - a[i] > 0) {
        d[i][j] = (p[i - 1][j] - p[i - 1][j - a[i] - 1]) % mod;
      } else {
        d[i][j] = p[i - 1][j] % mod;
      }
      if (j > 0)
        p[i][j] = (p[i][j - 1] + d[i][j]) % mod;
      else
        p[i][j] = d[i][j] % mod;
    }
  }
  cout << d[n][k];
  return 0;
}
