#include <bits/stdc++.h>
using namespace std;
inline int random(int _min, int _max) {
  static bool first = true;
  if (first) {
    srand(time(NULL));
    first = false;
  }
  return _min + rand() % ((_max + 1) - _min);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
inline long long int exp(long long int a, long long int b) {
  a %= 1000000007;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a % 1000000007;
    }
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
inline int add(int a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 1000000007) a += 1000000007;
  return a;
}
inline int multi(long long int a, long long int b) {
  a *= b;
  if (a >= 1000000007) a %= 1000000007;
  return a;
}
inline int on_bit(int N, int pos) { return N = N | (1 << pos); }
inline int off_bit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool check_bit(long long int N, int pos) {
  return (bool)(N & (1 << pos));
}
int main() {
  vector<long long int> dp(100005);
  dp[0] = 1;
  int n = ({
    int __II;
    scanf("%d", &__II);
    __II;
  }),
      k = ({
        int __II;
        scanf("%d", &__II);
        __II;
      });
  for (int kid = 1; kid <= n; ++kid) {
    int mx_candy_can_have = ({
      int __II;
      scanf("%d", &__II);
      __II;
    });
    vector<long long int> fake(k + 1);
    for (int candy = k; candy >= 0; --candy) {
      long long int value = dp[candy];
      int lo = candy + 1, hi = min(candy + mx_candy_can_have, k);
      if (lo <= hi) {
        fake[lo] += value;
        if (hi + 1 <= k) fake[hi] -= value;
      }
    }
    long long int prefix_sum = 0;
    for (int i = 0; i < fake.size(); i++) {
      prefix_sum = add(prefix_sum, fake[i]);
      dp[i] = add(dp[i], prefix_sum);
    }
  }
  printf("%lld\n", dp[k]);
  return 0;
}
