At the highest point, the vertical velocity is zero. The horizontal velocity is $v_x = u sinθ$. The kinetic energy at the top is $K_{top} = (1/2)m(u sinθ)^2 = E sin^2θ$. By conservation of energy, the potential energy at the top is $PE = E_{total} - K_{top} = E - E sin^2θ = E(1-sin^2θ) = E cos^2θ.