import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

dp = [[0]*(k+1) for _ in range(n+1)]
cum = [1]*(k+2)
M = 10**9+7
for i in range(n+1):
    dp[i][0] = 1
cum[0] = 0
for i in range(1,n+1):
    current = [0]*(k+2)
    for j in range(k+1):
#         print(i,j,k,a[i])
        dp[i][j] = (cum[j+1] - cum[max(0, j-min(k,a[i-1]))]) % M
        current[j+1] = (current[j] + dp[i][j])%M
    cum = current
print(dp[n][k])