#P7860. Stick Movement Ordering

    ID: 21045 Type: Default 1000ms 256MiB

Stick Movement Ordering

Stick Movement Ordering

There are n sticks placed on a table, each represented by a point on the x-axis. All sticks will be moved leftwards toward the table's edge (located at x = 0) at the same constant speed. However, only one stick can be moved at a time while the others remain stationary.

When a stick is moved, it travels continuously from its initial position to the table's edge. In order to avoid collisions, no other stick may lie between its starting position and x = 0 at the time of its movement.

It can be mathematically proven that the only safe strategy is to always move the stick with the smallest current x-coordinate. In other words, given a set of sticks with positions \(a_1, a_2, \dots, a_n\) on the x-axis, a valid move order is given by a permutation \(p_1, p_2, \dots, p_n\) such that \[ a_{p_1} < a_{p_2} < \dots < a_{p_n}, \] where we assume that the sticks are 1-indexed according to their input order.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 105), representing the number of sticks.

The second line contains n space-separated integers \(a_1, a_2, \dots, a_n\) (1 ≤ \(a_i\) ≤ 109), where \(a_i\) denotes the x-coordinate of the i-th stick.

outputFormat

Output a permutation of integers from 1 to n (1-indexed), representing the order in which the sticks are moved. The numbers should be separated by a single space.

sample

3
3 1 2
2 3 1