#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=1e18;
const ll maxs = 100005;
const ll mod = 1e9+7;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n,k;
ll a[maxs];
ll dp[2][maxs];
ll sum[2][maxs];

void solve()
{
    for(ll i=0;i<=k;i++)
        sum[0][i]=1;
    
    ll last=0,now=1;
    for(ll i=0;i<n;i++)
    {
        ll limit = a[i];
        for(ll i=0;i<=k;i++)
            sum[now][i]=0 , dp[now][i]=0;
        for(ll j=0;j<=k;j++)
        {
            if(j<=limit)
                dp[now][j] = sum[last][j];
            else
                dp[now][j] = sum[last][j] - sum[last][j-limit-1];
            sum[now][j]=sum[now][j-1]+dp[now][j];    
        }
        /*for(ll i=0;i<=k;i++)
            cout<<sum[0][i]<<" ";
        cout<<"\t";
        for(ll i=0;i<=k;i++)
            cout<<dp[0][i]<<" ";
        line;    
       for(ll i=0;i<=k;i++)
            cout<<sum[1][i]<<" ";
        cout<<"\t";
        for(ll i=0;i<=k;i++)
            cout<<dp[1][i]<<" ";
        line;  
        line;*/
        swap(last,now);
    }
    
    cout<<dp[last][k]; 
   
}

int main() {
    fastio();
    ll t=1;
    //cin>>t;
    while(t--){
        cin>>n>>k;
        for(ll i=0;i<n;i++)
            cin>>a[i];
        solve();
    }
	return 0;
}