#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T sqr(T a) {
  return a * a;
}
template <typename T>
T cube(T a) {
  return a * a * a;
}
template <typename T>
inline void smin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void smax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T>
inline void Int(T &n) {
  n = 0;
  int f = 1;
  register int ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << ", ";
  err(++it, args...);
}
inline int in() {
  int n;
  scanf("%d", &n);
  return n;
}
inline long long Lin() {
  long long n;
  scanf("%lld", &n);
  return n;
}
inline double Din() {
  double n;
  scanf("%lf", &n);
  return n;
}
inline int add(int a, int b, int mod) {
  a += b;
  return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod) {
  a -= b;
  return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod) { return (long long)a * b % mod; }
const int N = 2e5 + 5;
const long long Mod = (long long)1e9 + 7;
const int inf = (int)2e9;
const long long Inf = (long long)1e18;
const int mod = (int)1e9 + 7;
int solve() {
  int n = in(), k = in();
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int child = 1; child <= n; child++) {
    int upto = in();
    vector<int> prefix(k + 1);
    for (int used = k; used >= 0; used--) {
      int tem = dp[used];
      int l = used + 1, r = min(k, used + upto);
      prefix[l] = add(prefix[l], tem, mod);
      if (r + 1 <= k) prefix[r + 1] = sub(prefix[r + 1], tem, mod);
    }
    int sum = 0;
    for (int i = 1; i <= k; i++) {
      sum = add(sum, prefix[i], mod);
      dp[i] = add(dp[i], sum, mod);
    }
  }
  printf("%d\n", dp[k]);
  return 0;
}
int main() {
  int test = 1, tc = 0;
  while (test--) {
    solve();
  }
  return 0;
}
