#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
const unsigned long long int mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const long long int lmx = LLONG_MAX;
const long long int lmn = LLONG_MIN;
inline unsigned long long int powm(unsigned long long int x,
                                   unsigned long long int y, bool b = false,
                                   unsigned long long int m = mod) {
  if (b) {
    unsigned long long int t = 1;
    x %= m;
    while (y > 0) {
      if (y % 2) t = (t * x) % m;
      y = y >> 1;
      x = (x * x) % m;
    }
    return t;
  } else {
    unsigned long long int t = 1;
    while (y > 0) {
      if (y & 2) t *= x;
      y = y >> 1;
      x *= x;
    }
    return t;
  }
}
inline long long int gcd(long long int a, long long int b) {
  a = abs(a);
  b = abs(b);
  while (b != 0) {
    long long int c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  long long int k;
  cin >> n >> k;
  long long int a[n];
  for (int qw = 0; qw < (n); qw++) cin >> (a)[qw];
  long long int z[n + 1][k + 1];
  memset(z, (0), sizeof(z));
  z[0][0] = 1;
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (k); (j)++)
      z[i][j + 1] = (z[i][j + 1] + z[i][j]) % mod;
    for (int(j) = 0; (j) < (k + 1); (j)++) {
      z[i + 1][j] = z[i][j];
      if (j - a[i] - 1 >= 0) z[i + 1][j] -= z[i][j - a[i] - 1];
      z[i + 1][j] %= mod;
    }
  }
  cout << z[n][k];
}
