#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long INF = ((1LL << 62) - (1LL << 31));
template <typename T, typename U>
using mapv = map<T, vector<U>>;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
vector<vector<T>> genarr(long long n, long long m, T init) {
  return vector<vector<T>>(n, vector<T>(m, init));
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}";
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
    os << *itr;
    itr++;
    if (itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
    os << *itr;
    itr++;
    if (itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { cerr << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
  cerr << head;
  if (sizeof...(Tail) > 0) {
    cerr << ", ";
  }
  dump_func(std::move(tail)...);
}
const long long MOD = 1e9 + 7;
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  long long max_a = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    chmax(max_a, A[i]);
  }
  long long alpha = max_a + 10;
  auto dp = genarr(N + 10, K + alpha + 10, 0LL);
  auto s = genarr(N + 10, K + alpha + 10, 0LL);
  dp[0][alpha] = 1;
  for (int i = 0; i < N; i++) {
    long long a = A[i];
    for (int _j = 0; _j < K + 1; _j++) {
      long long j = _j + alpha;
      s[i][j] += dp[i][j] - dp[i][j - a - 1] + s[i][j - 1];
      s[i][j] %= MOD;
      dp[i + 1][j] = s[i][j];
    }
  }
  cout << dp[N][K + alpha] % MOD << endl;
  return 0;
}
