Skip to content
UPEEC

Leaders in an Array

Easy#arrays· solved by 0 · time limit 2.0 s

An element is a leader if it is strictly greater than every element to its right (the last element is always a leader). Print the leaders in their original order.

Input

nn, then nn integers.

Output

The leaders.

Constraints

1≤n≤1051 \le n \le 10^5

Sample 1

Input

6
16 17 4 3 5 2

Output

17 5 2

Sign in or join free to run and submit your solution.