N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [0]*(K+1)
dp[0] = 1
MOD = 10**9 + 7
for i in range(N):
    c = sum(dp[K-A[i]:K+1]) % MOD
    for j in range(K, -1, -1):
        v = dp[j]
        dp[j] = c
        c -= v
        if j-A[i]-1 >= 0:
            c += dp[j-A[i]-1]
        c %= MOD
print(dp[K])