#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(int w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, k;
    cin >> n >> k;
    BIT<modint<mod>> dp(k + 1);
    dp.add(0, 1);

    rep(i, n) {
        int a;
        cin >> a;
        for(int j = k; j >= 0; j--)
            dp.add(j, dp.sum(j - a, j + 1) - dp.sum(j, j + 1));
    }

    cout << dp.sum(k, k + 1).a;

    return 0;
}

Measured memory_bytes: 1024