The Hamiltonian Mean Field Model: From Dynamics to Statistical Mechanics and Back