Energy levels and thermal equilibrium