#B4123. Flight Queue Adjustment

    ID: 11780 Type: Default 1000ms 256MiB

Flight Queue Adjustment

Flight Queue Adjustment

At the airport security checkpoint, there are \( n \) people in a queue. The \( i \)-th person in line has a flight departing in \( t_i \) minutes. To avoid delays, the airport management decides to move all passengers whose flight departs in \( \leq 15 \) minutes to the front of the queue, while keeping their original relative order. The rest of the passengers remain in their original order after them.

Your task is to output the rearranged queue where, for each person, you only need to output the number of minutes until their flight departs.

inputFormat

The first line contains an integer \( n \) (\( 1 \leq n \leq 10^5 \)) representing the number of people in the queue.

The second line contains \( n \) space-separated integers \( t_1, t_2, \ldots, t_n \) (\( 0 \leq t_i \leq 10^9 \)) where \( t_i \) is the number of minutes until the \( i \)-th person's flight departs.

outputFormat

Output \( n \) integers in one line representing the adjusted order of flight departure times.

sample

5
5 20 10 25 15
5 10 15 20 25