n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n)]

for j in range(a[0] + 1):
    dp[0][j] = 1

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

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