#include <bits/stdc++.h>
using namespace std;
inline char gc() { return getchar(); }
template <class T>
int read(T &ans) {
  ans = 0;
  char ch = gc();
  T f = 1;
  while (!isdigit(ch)) {
    if (ch == EOF) return -1;
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}
template <class T1, class T2>
int read(T1 &a, T2 &b) {
  return read(a) != EOF && read(b) != EOF ? 2 : EOF;
}
template <class T1, class T2, class T3>
int read(T1 &a, T2 &b, T3 &c) {
  return read(a, b) != EOF && read(c) != EOF ? 3 : EOF;
}
const int Maxn = 110000;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
int n, k, x;
long long f[Maxn], g[Maxn];
signed main() {
  read(n, k);
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    read(x);
    int sum = 0;
    for (int j = 0; j <= x; j++) {
      sum += f[j];
      sum %= mod;
      g[j] = sum;
    }
    for (int l = 0, r = x + 1; r <= k; l++, r++) {
      sum += f[r] - f[l];
      sum %= mod;
      g[r] = sum;
    }
    memcpy(f, g, sizeof(f));
  }
  printf("%d", f[k]);
  return 0;
}
