Hadithcore
Hadith #2105190

Narrated 'Ali bin Abi Talib (RA):

Allah's Messenger (ﷺ) said: "If one of you comes to Salat (prayer) and the Imam is at a certain position, he must do as the Imam is doing." [Reported by at-Tirmidhi with a weak chain of narrators].

وَعَنْ عَلِيٍّ ‏- رضى الله عنه ‏- قَالَ: قَالَ اَلنَّبِيُّ ‏- صلى الله عليه وسلم ‏-{ إِذَا أَتَى أَحَدُكُمْ اَلصَّلَاةَ وَالْإِمَامُ عَلَى حَالٍ, فَلْيَصْنَعْ كَمَا يَصْنَعُ اَلْإِمَامُ } رَوَاهُ اَلتِّرْمِذِيُّ بِإِسْنَادٍ ضَعِيفٍ .‏ [1]‏ .‏

References2 variants
Sunnah.com reference
Book 2, Hadith 335
Arabic/English book reference
Book 2, Hadith 423