Find the greater element


it showing one wrong answer but my algo is correct.

@ankitdelhi20
Your code gives wrong outputs for inputs n <= 2.

Input :
2
8 5

Expected Output :
-1 8

Your Output :
8