import sys
input = sys.stdin.readline

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

for i in range(N):
    for j in range(K+1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][min(K, j+a[i])+1] -= dp[i][j]
        
    dp[i+1][0] %= MOD
    
    for j in range(1, K+2):
        dp[i+1][j] += dp[i+1][j-1]
        dp[i+1][j] %= MOD
    
print(dp[N][K])