Energetics of the spin transition in LaCoO 3