#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main()
{
    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int dp[k+1] = {0};
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        vector<int>fake(k+1,0);
        for(int j=0;j<=k;j++){
            int l = j+1;
            int r = j+ min(A[i-1],k);
            int temp = dp[j];
            if(l<=r){
                fake[l] = (fake[l]%1000000007 + temp%1000000007)%1000000007;
                if(r+1<=k){
                    fake[r+1] = (fake[r+1]%1000000007-temp%1000000007)%1000000007;
                }
            }
        }
        int prefix_sum = 0;
        for(int p=0;p<=k;p++){
            prefix_sum = prefix_sum%1000000007 + fake[p];
        	dp[p] =(dp[p]%1000000007 + prefix_sum%1000000007)%1000000007;
    	}
    }
    
    
    cout<<dp[k]%1000000007<<endl;
	return 0;
}
