n, k = [int(x) for x in input().split()]

arr = [int(x) for x in input().split()]

# dp[i] -> number of ways to distribute i candies to n childers
MOD = 10**9 + 7
dp = [0]*(k+1)

dp[0] = 1
pref = [0] + [1]*(k+1)
for i in range(n):
    for left in range(k,0,-1):
        dp[left] += pref[left] - pref[left - min(arr[i],left)]
        dp[left] %= MOD
        # for give in range(1,min(arr[i],left)+1):
        #     dp[left] += dp[left-give]
    pref = [0]
    for e in dp:
        pref.append(pref[-1] + e)

print(dp[k]%MOD)
