\delta\int \mathcal{L}dt=\delta\int\left(\sum_{i}P_i\dot{Q}_i-\mathcal{H}\right)dt=0