ADAUSORT - Ada and Unstable Sort

Ada the Ladybug had a lecture about algorithms. She learned that sorting can be done in O(NlogN) time. She also learned concept of stable sort. For those who missed the lecture, it means that as long as there are two equal elements in the array their mutual position won't change after the sort.

Ada wanted to come up with something new, so she proposed unstable sort. It is sort with following property: "As long as there are two equal elements in the array their mutual position will change after the sort".

As Ada has only theoretical knowledge about it, she has asked you to construct such algorithm for her.

Input

The first line of each test-case will contain an integer 1 ≤ N ≤ 105, the length of an array.

The next line will contain N integers 1 ≤ Ai ≤ 105, the elements of the array.

Output

For each test-case, print N numbers, the indexes of each element on which it was in original array. Indexes start with 1.

Example Input

4
1 2 3 4

Example Output

1 2 3 4

Example Input

3
3 2 1

Example Output

3 2 1

Example Input

6
6 6 6 6 6 6

Example Output

6 5 4 3 2 1

Example Input

5
5 5 2 2 3

Example Output

4 3 5 2 1

Example Input

6
1 2 1 2 1 2

Example Output

5 3 1 6 4 2

Added by:Morass
Date:2017-10-08
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Tunisian Collegiate Training Contest - Round #01

hide comments
2021-01-11 16:53:39
I don't understand the statement either. Ada asks us to implement a sorting algorithm, but output describes "original array", not defined anywhere but implying a reverse process. Moreover, the original array in last example appears to be [1, 2, 2, 1, 1, 2] which doesn't fit either concept. Morass, please clarify.

Edit: Got it. We do have to sort the input array and output indexes reflecting the target ordering.

Last edit: 2021-01-11 22:27:08
2020-06-12 09:16:13
@aditya_rev stl sort works ! but you have to create your own comparator function
2019-07-03 16:02:35
unable to understand the question

2018-04-10 20:54:53
my solution id is 21502836
plz answer where i am wrong


Last edit: 2018-04-10 20:55:29
2018-01-22 11:36:55
What will be the output for
3
1 1 1
2017-11-20 13:03:44
@aditya_rev: Well it might depend on how you use it ;-)
2017-11-18 19:38:14
Well.. sort stl wont works :)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.