e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Maximums to the right

Maximums to the right

Given array of n integers. Move all maximum elements to the end of the array without changing the order of others.

Input

First line contains positive integer n. Next line contains n integers. All numbers do not exceed 100 by absolute value.

Output

Print the elements of updated array.

Time limit 1 second
Memory limit 128 MiB
Input example #1
7
6 -2 7 1 7 -1 2
Output example #1
6 -2 1 -1 2 7 7
Author Matviychuk Sergiy Volodymyrovych
Source "ABC programming"