#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1e9 + 7;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

int n, k;
int dp[100005];

int32_t main()
{
    IOS;

    cin >> n >> k;
    // arr.resize(n);
    memset(dp, 0, sizeof dp);
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        int lmt;
        cin >> lmt;
        for (int used = k; used >= 0; used--)
        {
            int tmp = dp[used];
            int fake[k + 1] = {};
            int l = used + 1;
            int r = used + min(lmt, k - used);
            if (l <= r)
            {
                fake[l] += tmp;
                if (r + 1 <= k)
                    fake[r + 1] -= tmp;
            }
            int pp = 0;
            for (int i = 0; i <= k; i++)
            {
                pp += fake[i];
                dp[i] += pp;
            }
        }
    }
    cout << dp[k];

    return 0;
}