LearnPy Hub
← Arena
EasyRating 1000

Leaders

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

Input

n, then n integers.

Output

One line.

Sample 1

Input
6
16 17 4 3 5 2
Output
17 5 2

Sample 2

Input
1
9
Output
9
solution.py
Output appears here
Leaders · Python Arena problem · LearnPy Hub