MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k + 1)
# dp[i] - the number of ways such that we used i candies so far
dp[0] = 1
for i in range(n):
    fake = [0] * (k + 1)
    for used in range(k, -1, -1):
        tmp = dp[used]
        L = used + 1
        R = used + min(a[i], k - used)
        if L <= R:
            fake[L] = (fake[L] + tmp) % MOD
            if R + 1 <= k:
                fake[R + 1] = (fake[R + 1] - tmp + MOD) % MOD
    prefix_sum = 0
    for j in range(k + 1):
        prefix_sum = (prefix_sum + fake[j]) % MOD
        dp[j] = (dp[j] + prefix_sum) % MOD
print(dp[k])