#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  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() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<vector<mint> > dp(n + 1, vector<mint>(k + 1));
  for (int i = 0; i < (k + 1); i++) dp[0][i] = 1;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (k + 1); j++) {
      dp[i + 1][j] = dp[i][j];
      if (j - a[i] >= 1) dp[i + 1][j] -= dp[i + 1][j - a[i] - 1];
    }
    for (int j = 0; j < (k); j++) dp[i + 1][j + 1] += dp[i + 1][j];
  }
  mint ans = dp[n][k] - dp[n][k - 1];
  cout << ans.x << endl;
}
