The S&P 500 erased earlier losses and rose slightly to a record on Monday as investors prepared for a busy week of earnings featuring reports from the largest tech companies.