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

MOD = 10 ** 9 + 7

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

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

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