def main():
    N, K = map(int, input().split())
    if K == 0:
        return 1
    A = list(map(int, input().split()))
    MOD = 10**9+7
    dp = [[0]*(K+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        a = A[i]
        for j in range(K+1):
            dp[i+1][j] += dp[i][j]
            if j+a+1 <= K:
                dp[i+1][j+a+1] -= dp[i][j]
        for j in range(K):
            dp[i+1][j+1] += dp[i+1][j]
        for j in range(K+1):
            dp[i+1][j] = dp[i+1][j] % MOD

    return dp[N][K]


print(main())
