// M - Candies  https://atcoder.jp/contests/dp/tasks/dp_m
/* 入力例
3 4
1 2 3
// →出力 5
*/
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    unsighned long long int a[N], dp[K + 1][N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int j = 0; j < N; j++) {
        dp[0][j] = 1;
    }
    for(int i = 1; i <= K; i++) {
        if(i <= a[0]) {
            dp[i][0] = 1;
        } else {
            dp[i][0] = 0;
        }
        for(int j = 1; j < N; j++) {
            if(a[j] == 0) {
                dp[i][j] = dp[i][j - 1];
            } else {
                if(i <= a[j]) {
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % (1000000000 + 7);
                } else {
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1 - a[j]][j - 1]) % (1000000000 + 7);
                }
            }
        }
    }
    cout << dp[K][N - 1] % (1000000000 + 7) << endl;
    return 0;
}
