# -*- coding: utf-8 -*-
"""
Created on Thu Jan 30 16:06:12 2020

@author: matsui
"""

import numpy as np



N, K=map(int,input().split())
a=input().split()
a=[int(i) for i in a]

dp=np.zeros([N+1,K+1])
s=np.zeros(K+1)

for i in range(a[0]+1):
    dp[1][i]=1
          
M=a[0]
for j in range(2,N+1):
    M+=a[j-1]
    dp[j][0]=1
    
    s[0]=dp[j-1][0]
    for i in range(1,min(K+1,M+1)):
        s[i]=s[i-1]+dp[j-1][i]
      
    for i in range(1,min(K+1,M+1)):
        dp[j][i]=s[i]
        if i>a[j-1]:
            dp[j][i]-=s[i-a[j-1]-1]

        if dp[j][i] > 1e9+7: dp[j][i]=dp[j][i]%(1e9+7)
            
            
print(int(dp[N][K]))