class BIT(object):
    def __init__(self, N, init=0, mod=1):
        self.N = N
        self.bit = [init for _ in range(N)]
        self.mod = mod

    def add(self, k, w):
        x = k
        while x < self.N:
            self.bit[x] += w % self.mod
            self.bit[x] %= self.mod
            x |= x + 1

    def sum(self, k):
        s = 0
        x = k - 1
        while x >= 0:
            s += self.bit[x]
            s %= self.mod
            x = (x & (x + 1)) - 1
        return s

MOD = 10 ** 9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

bit = BIT(k + 1, mod=MOD)
bit.add(0, 1)

for ai in a:
    for i in range(k, 0, -1):
        if ai >= i:
            x = bit.sum(i)
        else:
            x = bit.sum(i) - bit.sum(i - ai)
        bit.add(i, x % MOD)
print(bit.sum(k + 1) - bit.sum(k))
