S&P 500 CAPE ratio tops 40 for second time since 1871