All praise is due to Allah, and peace and blessings be upon our master, the Messenger of Allah.
It is obligatory to break off the prayer if the situation requires rescuing a person from destruction or certain harm. The number of people needed to meet the need breaks off their prayer, namely those who are able to rescue him, while the others remain in their prayer, because the preservation of life is among the greatest objectives of the Sharīʿah.
Allah the Exalted says {what means}: “And whoever saves one [life], it is as if he had saved mankind entirely” [al-Māʾidah/32]. The Messenger of Allah (peace and blessings be upon him) said: “There should be neither harm nor reciprocating harm.”
Imam al-ʿIzz ibn ʿAbd al-Salām (may Allah have mercy on him) said: “Rescuing drowning persons whose lives are protected under Islamic Law takes precedence over performing the prayer, because in Allah’s sight rescuing drowning persons whose lives are protected under Islamic Law is better than performing the prayer.” [Qawāʿid al-Aḥkām fī Maṣāliḥ al-Anām, Vol.1/p.66]. And Allah Almighty knows best.