import numpy as np


def f(n, k, a_s):
    md = 10 ** 9 + 7
    dp = np.zeros(k + 1, dtype=np.int64)
    dp[0] = 1
    for a in a_s[:-1]:
        dp = np.cumsum(dp)
        if k!=a:
            dp[k:a:-1] -= dp[k - a - 1::-1]
    return np.sum(dp[k - a_s[-1]:]) % md


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))
