n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [[0 for j in range(k+1)] for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
    t = 0
    for j in range(k+1):
        if j <= a[i-1]:
            t += dp[i-1][j]
        else:
            t += dp[i-1][j]
            t -= dp[i-1][j-a[i-1]-1]
        t %= 10**9+7
        dp[i][j] = t
print(dp[n][k])