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


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