Ion energy-loss spectroscopy for the collision of Ar+(2PJ) with H2 and N2