Print Elements Larger Than PreviousEasy

Print Elements Larger Than Previous

EasyPractice library · +10 XPstackbasic programmingiteration

Given a sequence of integers, print all elements that are strictly greater than all the elements that came before them in the sequence. Print the elements in the order they appear in the input.

Input

The first line contains an integer N, the number of elements in the sequence. The second line contains N integers, separated by spaces.

Output

Print the elements that are strictly greater than all preceding elements, separated by spaces. If no such elements exist, print nothing.

Constraints

1 <= N <= 1000, -10^9 <= A[i] <= 10^9

Time limit 1 s (native code; slower languages get more)Memory 256 MB12 hidden tests

Example 1

Input
5
1 3 2 5 4
Output
1 3 5

1, 3, and 5 are greater than all preceding elements.

Example 2

Input
3
5 4 3
Output
5

Only 5 is greater than all preceding elements (none).

Hints