N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
dp = [[0 for _ in range(K+1)] for _ in range(N+1)]
dq = [[0 for _ in range(K+2)] for _ in range(N+1)]
for j in range(K+1):
    if j>A[N]:
        dp[N][j] = 0
    else:
        dp[N][j] = 1
    dq[N][j+1] = dq[N][j]+dp[N][j]
for i in range(N-1,0,-1):
    for j in range(K+1):
        dp[i][j] = dq[i+1][j+1]-dq[i+1][max(0,j-A[i])]
        dq[i][j+1] = dq[i][j]+dp[i][j]
print(dp[1][K])