class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            s %= mod
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            self.tree[i] %= mod
            i += i & -i

    def show(self, i):
        return self.sum(i) - self.sum(i-1)


n, k = map(int, input().split())
mod = 10**9+7
A = tuple(map(int, input().split()))

# xこの飴をy人に分ける
dp = [Bit(k+1) for _ in range(n+2)]
for i, a in enumerate(A):
    if i == 0:
        for j in range(a+1):
            dp[i].add(j+1, 1)
        continue
    for j in range(a+1):
        dp[i].add(j + 1, (dp[i - 1].sum(j + 1)) % mod)
    for j in range(a+1, k+1):
        dp[i].add(j + 1, (dp[i - 1].sum(j + 1) - dp[i - 1].sum(j - a)) % mod)

print(dp[n-1].show(k+1))



