#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<vector<ll>> v;
    int n,k;
    cin>>n>>k;
    v.resize(n+1);
    for(int i=0;i<=n;i++)
    v[i].resize(k+1);
    ll a[n+1]={0};
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=0;i<=n;i++)
    v[i][0]=1;
    for(int i=0;i<=k;i++)
    v[0][i]=1;
    ll b[k+1]={0};b[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i==1)
            {
                 if(j<=a[1])
                 v[i][j]=1;
            }
            else
            {
           
            b[j]=(b[j-1]+v[i-1][j])%mod;//cout<<b[j]<<" ";
            if(a[i]>j)
            v[i][j]=b[j];
            else if(a[i]<j)
           { v[i][j]=(b[j]-b[j-a[i]-1]);if(j==a[i])v[i][j]++;}
           else
           {
               v[i][j]=b[j];
           }
            }//cout<<v[i][j]<<" ";
        }//cout<<endl;
    }
    cout<<v[n][k]%mod;
    return 0;
}