
def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [[0]*(K+1) for _ in range(N+1)]
    # init 0個配る状態は1通り
    for i in range(N+1):
        dp[i][0] = 1

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

    print(dp[N][K])


if __name__ == "__main__":
    resolve()