def main():

    N, K = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[0]*(K+1) for i in range(N+1)]
    import collections
    mod = 10**9 + 7
    # dp[i][j] i人目まで配って、残りがj個の方法の数
    s = [1]*(K+2)
    s[-1] = 0
    tmp = 0
    for i in range(1, N+1):
        next = [0]*(K+2)
        for j in range(K, -1, -1):
            tmp = s[j] - s[min(K, j+a[i-1]) + 1]
            tmp %= mod
            dp[i][j] = tmp
            next[j] = (next[j+1]+tmp) % mod
        s = list(next)

    print(tmp)


main()
