mod = 10 ** 9 + 7

n, k = map(int, input().split())
a = tuple(int(x) for x in input().split())

d = tuple([0] * (k + k + 1) for _ in range(n + 1))
d[0][0] = 1

# もらう
for pind, lim in enumerate(a, 1):
    csum = [0]
    t = 0
    for cnt in range(k + 1):
        t += d[pind - 1][cnt]
        csum.append(t)
    for distributed in range(k + 1):
        d[pind][distributed] = (csum[distributed + 1] - csum[max(0, distributed - lim)]) % mod

print(d[n][k])