Next greater Element
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given an array, print the Next Greater Element for every element.
The Next Greater Element for an element is the first greater element on the right side of in the array. Elements for which no greater element exist, consider the next greater element as .
Input
The first line contains number . The second line contains positive integers, each not greater than .
Output
For each element of input array print the Next Greater Element.
Examples
Input #1
Answer #1
Submissions 566
Acceptance rate 74%