Temperature & Distance of Mercury

Mercury is the closest planet to the sun. But although it boasts the most widely varying temperatures in the solar system, it is not the hottest planet.  How is this possible?

Orbiting between 28 and 43 million miles (46 and 70 million kilometers) from the sun, Mercury, also the smallest planet, feels the brunt of the solar rays. The planet has an average temperature of 332 degrees Fahrenheit (167 degrees Celsius) The day side of the planet reaches temperatures of up to 801 F (427 degrees C). In contrast, the chilly night side can get as cold as minus 279 F (minus 173 C).