N, K = map(int, input().split())
M=10**9+7
As = list(map(int, input().split()))
dp = [[0]*(K+1)for _ in range(N+1)]
dp2 = [[1]*(K+1)for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(K+1):
#        print(i,j, dp[i][j-1] - dp2[i][j-1] + dp[i-1][j], j-As[i-1])
        dp[i][j] = 1 if j==0 else (dp[i][j-1] - dp2[i][j-1] + dp[i-1][j])%M
        dp2[i][j] = 0 if j-As[i-1] <0 else dp[i-1][j-As[i-1]]%M
#        dp[i][j] = sum(dp[i-1][max(0, j-As[i])...j])
#        sum(dp[i][0...j]) = sum(dp[i-1][max(0,j-As[i])...j])
#        dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + ... dp[i-1][max(0, j-As[i])]
#print(dp,dp2)
print(dp[N][K])
