#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ll n,k,temp=0;     cin>>n>>k;      vii v(n+1,0);
    forin(0,n)  cin>>v[i+1];
    vector<vii> dp(n+1);
    for(auto &i : dp)   i.resize(k+1,0);
    forin(0,n+1) dp[i][0] = 1;
    vii pre(n+1,0);
    forin(1,n+1)
    {
        temp=0;
        for(ll j=0;j<k+1;++j)
        {
            temp += dp[i-1][j];
            pre[j] = temp;
        }
        for(ll j=1;j<k+1;++j)
        {
            dp[i][j] = pre[j]  - (j-v[i]<=0 ? 0 : pre[j-v[i]-1]);
        }
    }
    cout<<dp[n][k]<<endl;

}
