#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(K+1);
    A[0] = 1;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        vector<long long> B(K+1);
        B[0] = A[0];
        for (int j = 1; j <= K; j++) {
            B[j] = B[j-1] + A[j];
        }
        for (int j = K; j >= 0; j--) {
            int lo = max(0, j - a);
            int hi = j;
            A[j] = (B[hi] - B[lo] + A[lo]) % MOD;
        }
    }
    cout << A[K] << endl;
    return 0;
}