#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;


template<int64_t mod>
struct ModInt {
    int64_t value;

    ModInt() : value(0) {}
    ModInt(int64_t x) : value(x >= 0 ? x % mod : (mod - ((-x) % mod) % mod)) {}

    ModInt &operator+=(const ModInt &input) {
        value += input.value;
        if (value >= mod) value -= mod;
        return *this;
    }    

    ModInt &operator-=(const ModInt &input) {
        value += (mod - input.value);
        if (value >= mod) value -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &input) {
        value = value * input.value % mod;
        return *this;
    }

    ModInt &operator/=(const ModInt &input) {
        *this *= input.inverse();
        return *this;
    }

    ModInt inverse() const {
        int64_t base = value, p = mod;
        pair<int64_t, int64_t> save = {1, 0};
        while (p) {
            int64_t temp = base / p;
            swap(base -= temp * p, p);
            swap(save.first -= temp * save.second, save.second);
        }
        return ModInt(save.first);
    }

    ModInt operator-() const { return ModInt(-value); }

    ModInt operator-(const ModInt &input) const { return ModInt(*this) -= input; }

    ModInt operator+(const ModInt &input) const { return ModInt(*this) += input; }

    ModInt operator*(const ModInt &input) const { return ModInt(*this) *= input; }

    ModInt operator/(const ModInt &input) const { return ModInt(*this) /= input; }

    bool operator==(const ModInt &comparsion) const { return value == comparsion.value; }

    bool operator!=(const ModInt &comparsion) const { return value != comparsion.value; }

    friend istream &operator>>(istream &stream, ModInt &input) {
        int64_t temp;
        stream >> temp;
        input = ModInt<mod>(temp);
        return stream;
    }

    friend ostream &operator<<(ostream &stream, const ModInt &input) {
        return stream << input.value;
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), x(value);
        while (n > 0) {
            if (n and 1) ret *= x;
            x *= x;
            n >>= 1;
        }
        return ret;
    }

    static const int64_t get_mod() { return mod; }
};

using modint = ModInt<MOD>;

template<typename T>
class CumulativeSum {
private:
    vector<T> data;

public:
    explicit CumulativeSum(size_t size) : data(size, 0) {}

    void update(size_t index, T value) {
        data[index] += value;
    }

    virtual void build() {
        for (size_t index = 0; index + 1 < data.size(); index++) data[index + 1] += data[index];
    }

    T sum(size_t index) {
        if (index < 0) return 0;
        return data[index];
    }

    T sum_all() {
        return sum(data.size() - 1);
    }

    /// [left, right)
    T query(size_t left_index, size_t right_index) {
        T ret = left_index == 0 ? 0 : sum(left_index - 1);
        return sum(right_index - 1) - ret;
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> candy(N);
    for (int i = 0; i < N; i++) cin >> candy[i];
    vector<CumulativeSum<modint>> dp(N, CumulativeSum<modint>(K + 5));
    // init
    for (int i = 0; i <= candy[0]; i++) dp[0].update(i, 1); 
    for (int i = 1; i < N; i++) {
        dp[i - 1].build();
        for (int j = 0; j <= K; j++) {
            int left = max(0, (j - candy[i]));
            int right = j;
            dp[i].update(j, dp[i - 1].query(left, right + 1));
        }
    }
    dp[N - 1].build();
    cout << dp[N - 1].query(K, K + 1) << endl;
}

Measured memory_bytes: 79360