n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 10**9 + 7

dp = [[0 for _ in range(k+1)] for __ in range(n)]

sm = 0

for i in range(n):
    sm += a[i]
    for j in range(k+1):
        if j == 0:
            dp[i][j] = 1
            continue
        if sm < j:
            dp[i][j] = 0
        else:
            if j-1-a[i] >= 0:
                dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1-a[i]]
            else:
                dp[i][j] = dp[i][j-1] + dp[i-1][j]
            dp[i][j] %= mod

print(dp[n-1][k])
