Search for heavy narrow dilepton resonances in pp collisions at sqrt(s) = 7 TeV and sqrt(s) = 8 TeV