MOD = int(1e9 + 7)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [[0] * (K+1) for _ in range(N+1)]
    dp[0][K] = 1

    for i in range(N):
        cumsum = [0] * (K+2)
        for j in range(K+1):
            cumsum[j+1] = cumsum[j] + dp[i][j]
        for j in range(K+1):
            dp[i+1][j] = (cumsum[min(j+A[i]+1, K+1)] - cumsum[j]) % MOD
    print(dp[N][0])


if __name__ == "__main__":
    main()
