
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(N):
        cum = [0]*(K+2)
        for j in range(K + 1):
            cum[j+1] = (cum[j] + dp[i][j]) % MOD
        for j in range(K+1):
            idx = max(0, j - A[i])
            dp[i+1][j] = cum[j+1] - cum[idx]
            dp[i + 1][j] = (dp[i+1][j]+MOD)%MOD

    print(dp[N][K])

if __name__ == "__main__":
    resolve()