Question
Arena Clash
In a distant realm, Queen Elara wishes to end a conflict among N rival fighters, each possessing a specific power value.
These fighters are locked in a coliseum and may attack one another. When one fighter attacks another, only the defender’s power is reduced—specifically, it decreases by the attacker’s power.
The attacker does not lose any power.
A fighter is eliminated from the battle once their power drops below 1. The battle continues until only one fighter remains.
Assuming all fighters act in a way that leads to the lowest possible final power of the sole survivor, determine what that minimum power can be.
Input
The first line of the input contains a single integer N.
The second line of the input contains N space-separated integers H1, H2,. ..., HN denoting the health of the fighter.
The second line of the input contains N space-separated integers H1, H2,. ..., HN denoting the health of the fighter.
Output
Find the minimum possible final health of the last alive fighter.
Example
Sample Input
4
2 20 10 30
Sample Output
2
Explanation
By strategically having higher-powered fighters (20, 10, 30) attack each other to deplete their strengths (e.g., 30 attacks 20, then 10, etc.), the fighter with power 2 can remain untouched and survive with the smallest possible power. Thus, the answer is 2.
4
2 20 10 30
Sample Output
2
Explanation
By strategically having higher-powered fighters (20, 10, 30) attack each other to deplete their strengths (e.g., 30 attacks 20, then 10, etc.), the fighter with power 2 can remain untouched and survive with the smallest possible power. Thus, the answer is 2.