#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
struct Mint {
  long long x;
  Mint() : x(0) {}
  Mint(long long _x) : x((_x % mod + mod) % mod) {}
  Mint& fix() {
    x = (x % mod + mod) % mod;
    return *this;
  }
  Mint& operator+=(const Mint& other) {
    if ((x += other.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  Mint& operator-=(const Mint& other) {
    if ((x += mod - other.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  Mint& operator*=(const Mint& other) {
    (x *= other.x) %= mod;
    return *this;
  }
  Mint operator+(const Mint& other) const { return Mint(*this) += other; }
  Mint operator-(const Mint& other) const { return Mint(*this) -= other; }
  Mint operator*(const Mint& other) const { return Mint(*this) *= other; }
  Mint operator-() const { return Mint(0) - *this; }
  Mint operator++(int) {
    Mint result(*this);
    *this += 1;
    return result;
  }
  Mint operator--(int) {
    Mint result(*this);
    *this -= 1;
    return result;
  }
  bool operator<(const Mint& other) const { return x < other.x; }
  bool operator==(const Mint& other) const { return x == other.x; }
};
ostream& operator<<(ostream& out, const Mint& val) { return out << val.x; }
istream& operator>>(istream& in, Mint& val) {
  in >> val.x;
  return in;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<Mint> dp(k + 1);
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  dp[0] = 1;
  for (int j = 0; j < n; j++) {
    vector<Mint> p = dp;
    for (int i = 1; i <= k; i++) {
      p[i] += p[i - 1];
    }
    for (int i = 1; i <= k; i++) {
      dp[i] = p[i];
      if (i - a[j] - 1 >= 0) {
        dp[i] -= p[i - a[j] - 1];
      }
    }
  }
  cout << dp[k] << '\n';
  return 0;
}
