def main():
    mod = 10**9+7
    n,k = map(int,input().split())
    candies = list(map(int,input().split()))
    dp = [[0 for i in range(k+1)] for j in range(n+1)]
    dp[0][0] = 1
    for pos in range(1,n+1):
        for used in range(k+1):
            a = candies[pos-1]
            start = used
            end = min(start+a+1,k+1)
            dp[pos][start] += dp[pos-1][start]
            if end <= k:
                dp[pos][end] -= dp[pos-1][start]

        for used in range(1,k+1):
            dp[pos][used] += dp[pos][used-1]
            dp[pos][used] %= mod


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


main()
