The Prophet ﷺ said, "The people who receive the greatest reward for prayer are those who walk the farthest to reach it, and the one who waits to pray with the imam has a greater reward than the one who prays and then goes to sleep."
قال النبي ﷺ: أعظم الناس أجرا في الصلاة أبعدهم فأبعدهم ممشى، والذي ينتظر الصلاة حتى يصليها مع الإمام أعظم أجرا من الذي يصلي ثم ينام.
Bukhari narrated it in "The Book of Adhan" (651), and this is his wording, and Muslim narrated it in "The Book of Mosques" (662), both of them via Abu Usama, from Yazid bin Abdullah, from Abu Burda, from Abu Musa, and he added, "until he prays it with the imam in congregation."