#include <bits/stdc++.h>
using namespace std;
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 <typename T>
ostream& operator<<(ostream& s, const complex<T>& d) {
  return s << "(" << d.real() << ", " << d.imag() << ")";
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {
  return s << "(" << d.first << ", " << d.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& d) {
  int len = d.size();
  for (long long i = 0; i < len; i++) {
    s << d[i];
    if (i < len - 1) s << " ";
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& d) {
  int len = d.size();
  for (long long i = 0; i < len; i++) {
    s << d[i] << endl;
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const set<T>& v) {
  s << "{ ";
  for (auto itr = v.begin(); itr != v.end(); ++itr) {
    if (itr != v.begin()) {
      s << ", ";
    }
    s << (*itr);
  }
  s << " }";
  return s;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    s << " " << (*itr).first << " : " << (*itr).second << endl;
  }
  s << "}" << endl;
  return s;
}
const long long mod = 1e9 + 7;
const long long inf = 1e15;
const int INF = 1e9;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<mint>> dp(n + 1, vector<mint>(k + 1, 0));
  dp[0][0] = 1;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < k + 1; j++) {
      dp[i + 1][j] = dp[i][j] + dp[i + 1][j - 1];
      if (j - 1 >= a[i]) dp[i + 1][j] -= dp[i][j - 1 - a[i]];
    }
  cout << dp[n][k].x << endl;
}
