Consider a central force problem of the form with the Lagrangian $$ L(r, \theta, \dot{r}, \dot{\theta}) = \frac{1}{2} m \left( \dot{r}^2 + r^2 \dot{\theta}^2 \right) - V(r), $$ where $r = |\vec{x}|$. Since $\theta$ is cyclic, we can show that $m r^2 \dot{\theta}$ is a constant of motion, and rewrite the Lagrangian as $$ L(r, \dot{r}) = \frac{1}{2} m \dot{r}^2 + \frac{l^2}{2mr^2} - V(r). $$
If I calculate the Hamiltonian from this, I get $$ H_{1}(r, p_r) = \frac{p_r^2}{2m} - \frac{l^2}{2mr^2} + V(r) $$
Taking another direction, I calculated first the Hamiltonian from the Lagrangian as $$ H_{2}(r, \theta, p_r, p_{\theta}) = \frac{p_r^2}{2m} + \frac{p_{\theta}^2}{2mr^2} + V(r) = \frac{p_r^2}{2m} + \frac{l^2}{2mr^2} + V(r) = H_{2}(r, p_r), $$ where I concluded that $p_\theta = m r^2 \dot{\theta} = l$ is a constant.
The problem is, that I get an apparent sign difference between the $\frac{l^2}{2mr^2}$ and $V(r)$ terms in $H_{1}$ and $H_{2}$, which I don't understand. I'm pretty sure that $H_1$ is wrong, but I don't know what kind of conceptual mistake did I make when calculating $H_1$.
Conceptual issue
Apparently, when I introduce the additional potential term in the Lagrangian formalism first, then calculate the Hamiltonian, I don't get the same Hamiltonian when I do it in reverse order. Why do I get different Hamiltonians?