How the S&P 500 recovered all of its losses for the year