mod = 10 ** 9 + 7

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

a = [int(x) for x in input().split()]

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

for i in range(N):
    for j in range(K+1):
        if j == 0:
            dp[i][j] = 1
            continue
        if i == 0:
            if j <= a[i]:
                dp[i][j] = 1
            else:
                dp[i][j] = 0
            continue
        dp[i][j] = dp[i-1][j] + dp[i][j-1]
        if j > a[i]:
            dp[i][j] -= dp[i-1][j-1-a[i]]
        if dp[i][j] > mod:
            dp[i][j] -= mod

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