Find the greater element

What’s wrong with code ??

@Deepak_nsit
Consider a test case:
5
7 3 4 5 2
correct output : -1 4 5 7 7
your code gives : 4 5 -1 -1 -1

debug your code for this