TABARANI 3970:
from Abū Ayyūb al-Anṣārī —
[Machine] The Prophet ﷺ said, "Two men may go to the mosque and one of them will finish his prayer better than the other if he is more excellent in his intellect. The other will finish his prayer and it will not be equal to the weight of a small atom."
الطبراني ٣٩٧٠:
عن ابو ايوب الانصاري —
قَالَ النَّبِيُّ ﷺ «قَدْ يَتَوَجَّهُ الرَّجُلَانِ إِلَى الْمَسْجِدِ وَيَنْصَرِفُ أَحَدُهُمَا وَصَلَاتُهُ أَفْضَلُ مِنَ الْآخَرِ إِذَا كَانَ أَفْضَلَهُمَا عَقْلًا وَيَنْصَرِفُ الْآخَرُ وَصَلَاتُهُ لَا تَعْدِلُ مِثْقَالَ ذَرَّةٍ»
hadithunlocked.com