A history of phenotypic plasticity accelerates adaptation to a new environment