Shares inch up after sell-off pushes S&P 500 into bear market