def f(k, a_s):
    md = 10 ** 9 + 7
    dp = [0] * (k + 1)
    dp[0] = 1
    for a in a_s[:-1]:
        dp[-1], R = sum(dp[k - a:]) % md, dp[-1]
        for j in range(k - 1, a - 1, -1):
            dp[j], R = (dp[j + 1] - R + dp[j - a]) % md, dp[j]
        for j in range(a - 1, -1, -1):
            dp[j], R = (dp[j + 1] - R) % md, dp[j]
    return sum(dp[k - a_s[-1]:]) % md


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