Sayyiduna Samurah bin Jundub (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "Attend the sermon and sit close to the imam, for when a person keeps staying far away, Allah Almighty will keep him behind in Paradise too, even if he enters it."
This is how Abu Dawud narrated it from Ali (bin Abdullah), and that is the correct version.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجمعة / 5929