We get sun heat via radiation,so most people wonder why mountains are colder than valley,while mountains are closer to the sun.They are indeed correct since radioactive energy decreases with distance from the source.But the sun is over 150 million Km away and the difference between the highest mountain (Everest)and the lowest desert is 8000 m which is negligible compared to 150 million km.Therefore, it is not the distance!.
It has to do with the pressure.The pressure is low in the mountains(thin air/less molecules) and higher at the valleys(thick air/more molecules).Where denser thick air can store more heat. As we go up a mountain, the air becomes less dense and less heat can be absorbed.
But something else is going on. As we know the warmer air rises up(since it is less dense)while the colder air stays down,so in the process where the hot air rises its temperature drops down since it lose pressure(gas law).By the time the air reaches the high mountain it has lost a lot of pressure and so it freezes.