MOD = 10**9+7

N, K = map(int, input().split())
a = list(map(int, input().split()))

# i 番目までに j 枚使ったときの場合の数
dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1

upper = 0
for i in range(1, N+1):
    for j in range(1, K+1):
        dp[i-1][j] += dp[i-1][j-1]
    upper += a[i-1]
    for j in range(min(upper, K)+1):
        if j > a[i-1]:
            dp[i][j] = dp[i-1][j] - dp[i-1][j-a[i-1]-1]
        else:
            dp[i][j] = dp[i-1][j]
        dp[i][j] %= MOD

print((dp[N][K]+MOD)%MOD)