N, K = map(int, input().split())
A = [int(a) for a in input().split()]
P = 10**9+7
def cumsum(A):
    B = [A[0]]
    for i in range(1, len(A)):
        B.append((B[-1]+A[i])%P)
    return B

dp = [1] + [0] * (K+N)
for a in A:
    dp = [(dp[i]-(dp[i-a-1] if i>=a+1 else 0))%P for i in range(K+1)]
    dp = cumsum(dp)
print(dp[K])