As I was reading Goldstein, there is the Hamiltonian $H$ such that, $$\delta \int_{t1}^{t2} (p_i\dot q_i - H(q, p ,t)) dt = 0, \tag{9.7}$$ and Kamiltonian $K$, $$\delta \int_{t1}^{t2} (p_i\dot q_i - K(Q, P ,t)) dt = 0. \tag{9.6}$$ This is ok.
Then, $$\lambda(p_i\dot q_i - H) = P_i\dot Q_i - K + \frac{dF}{dt} \tag{9.8}$$ but I am not getting how this last expression does come. Here I am not understating why $\lambda$ and ${dF/dt}$ does come? If you know any mathematical article, paper that would be really helpful.