N, K = map(int, input().split())
*a, = map(int, input().split())

dp = [[1] + [0]*K for _ in range(N)]
for k in range(1, a[0]+1):
    dp[0][k] = 1

for i in range(1, N):
    for k in range(1, K+1):
        if k - a[i] - 1 >= 0:
            dp[i][k] = dp[i][k-1] + dp[i-1][k] - dp[i-1][k-a[i]-1]
        else:
            dp[i][k] = dp[i][k-1] + dp[i-1][k]
        dp[i][k] %= 1e9+7
        
print(int(dp[-1][-1]))