Lord Vader's Death Star

4

14 votes
Easy-Medium
Problem

Darth Vader, the lord of the dark side has created a Death-Star (it can destroy any star). You have to deactivate the Death-star. To deactivate the death-star one must find the unique most powerful Lightsaber. Lightsaber’s power is associated with a number. You ask for Lightsaber from your friendly Jedis(person). You should choose the Lightsaber which has the unique power as well as it is powerful enough.

Input::: First line of input contains N,denoting the number of Lightsabers. Next line contains N space separated numbers denoting the power(Ai) of each Lightsaber.

Output ::: Print power of the unique most powerful Lightsaber.If there is no such lightsaber present then print -1.

Constraints::: 1 ≤ N ≤ 10^6, 0 ≤ Ai ≤ 10^9.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?