#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long MOD = (long long)1e9 + 7;
const long long MOD2 = 1007681537;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-12;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, long long p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline long long chkmin(T &a, const T &val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline long long chkmax(T &a, const T &val) {
  return a < val ? a = val, 1 : 0;
}
inline void addmod(long long &a, long long val, long long p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(long long &a, long long val, long long p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline long long mult(long long a, long long b, long long p = MOD) {
  return (long long)a * b % p;
}
inline long long inv(long long a, long long p = MOD) {
  return fpow(a, p - 2, p);
}
template <class T>
inline void get_arr(T arr[], long long n) {
  for (long long i = 0; i < n; i++) cin >> arr[i];
}
template <class T>
inline void print_arr(T arr[], long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "\n";
}
int32_t main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> dp(n + 1);
  dp[0] = 1;
  for (long long child = 0; child < n; child++) {
    long long upto;
    cin >> upto;
    vector<long long> fake(k + 1);
    for (long long used = k; used >= 0; used--) {
      long long tmp = dp[used];
      long long L = used + 1;
      long long R = used + min(upto, k - used);
      if (L <= R) {
        addmod(fake[L], tmp);
        if (R + 1 <= k) {
          submod(fake[R + 1], tmp);
        }
      }
    }
    long long presum = 0;
    for (long long i = 0; i <= k; i++) {
      addmod(presum, fake[i]);
      addmod(dp[i], presum);
    }
  }
  cout << dp[k] << "\n";
}
