Problems
Next greater Element
Next greater Element
Given an array, print the Next Greater Element for every element.
The \textbf{Next Greater Element} for an element $x$ is the first greater element on the right side of $x$ in the array. Elements for which no greater element exist, consider the next greater element as $-1$.
\InputFile
The first line contains number $n\:(n \le 10^5)$. The second line contains $n$ positive integers, each not greater than $10^9$.
\OutputFile
For each element of input array print the Next Greater Element.
\includegraphics{https://eolympusercontent.com/images/foblfjllk14pd794mu1tqsiav0.gif}
Input example #1
10 5 3 8 5 7 4 2 1 3 7
Output example #1
8 8 -1 7 -1 7 3 3 7 -1