We study the stabilizability, via the method of energy shaping, of a given Lagrangian system with two degrees of underactuation and with n >= 4 degrees of freedom. By making use of the formal theory of PDEs, we derive an involutive system of PDEs which governs energy shapability, and thus deduce, for the first time, easily verifiable conditions under which energy shaping is guaranteed. We illustrate our results with an example of a three-cart-one-inverted pendulum system.