#include<bits/stdc++.h>
using namespace std;
#define INF 9223372036854;
#define lli long long int
const long int m = 1000000007;


int main()
{
    int n,k;
    cin>>n>>k;
    int dp[n+1][k+1];
    memset(dp,0,sizeof(dp));
    int arr[n] = {0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int i,j,x,l;
    for(i=0;i<=n;i++)
    {
        dp[i][0] = 1;
    }
    for(i=0;i<=k;i++)
    {
        dp[0][i] = 1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            x = min(arr[i-1],j);
            if(x==j)
            {
                dp[i][j] = dp[i-1][j]%m;
            }
            else
            {
                dp[i][j] = (dp[i-1][j]%m - dp[i-1][j-x-1]%m)%m;
            }
            dp[i][j] = (dp[i][j]%m+dp[i][j-1]%m)%m;
        }
    }
    if(k==0) cout << dp[n][k];
    else cout << dp[n][k]-dp[n][k-1];

}
