It is obligatory for the Imam who

A: Being mentally distracted during Salah (Prayer) does not invalidate it. However, one should free his heart, stop insinuations, and seek refuge in Allah against the devil three times when he starts offering Salah. He will only be rewarded for the parts of the Salah he is aware of.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.