Problem:
Score : 300 points

Problem Statement

Takahashi is a teacher responsible for a class of N students.

The students are given distinct student numbers from 1 to N.

Today, all the students entered the classroom at different times.

According to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).

From these records, reconstruct the order in which the students entered the classroom.

Constraints

1 \le N \le 10^5

1 \le A_i \le N

A_i \neq A_j (i \neq j)

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

Print the student numbers of the students in the order the students entered the classroom.

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

First, student number 3 entered the classroom.

Then, student number 1 entered the classroom.

Finally, student number 2 entered the classroom.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

1 2 3 4 5

Sample Input 3

8
8 2 7 3 4 5 6 1

Sample Output 3

8 2 4 5 6 7 3 1

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>

struct heap_ {
  int data[100000];
  int index[100000];
  int last;
};

struct heap_ heap;

void swap(int *x, int *y)
{
  int temp = *x;
  *x = *y;
  *y = temp;
}

void init()
{
  heap.last = -1;
}

void insert(int idx, int d)
{
  heap.last++;

  heap.index[heap.last] = idx;
  heap.data[heap.last] = d;

  int i = heap.last;
  while(i > 0) {
    if(heap.data[i] < heap.data[(i-1)/2]) {
      swap(&heap.index[i], &heap.index[(i-1)/2]);
      swap(&heap.data[i], &heap.data[(i-1)/2]);
      i = (i-1)/2;
    }
    else {
      break;
    }
  }
}

int deletemin()
{
  int min_idx = heap.index[0];

  heap.index[0] = heap.index[heap.last];
  heap.data[0]  = heap.data[heap.last];
  heap.last--;

  int i = 0;
  while(i < heap.last) {
    if(heap.data[i] > heap.data[i * 2 + 1] &&
       heap.data[i] > heap.data[i * 2 + 2] &&
       i * 2 + 2 <= heap.last) {
      if(heap.data[i * 2 + 1] < heap.data[i * 2 + 2]) {
        swap(&heap.data[i], &heap.data[i * 2 + 1]);
        swap(&heap.index[i], &heap.index[i * 2 + 1]);
        i = i * 2 + 1;
      }
      else {
        swap(&heap.data[i], &heap.data[i * 2 + 2]);
        swap(&heap.index[i], &heap.index[i * 2 + 2]);
        i = i * 2 + 2;
      }
    }
    else if(heap.data[i] > heap.data[i * 2 + 1] && i * 2 + 1 <= heap.last) {
      swap(&heap.data[i], &heap.data[i * 2 + 1]);
      swap(&heap.index[i], &heap.index[i * 2 + 1]);
      i = i * 2 + 1;
    }
    else if(heap.data[i] > heap.data[i * 2 + 2] && i * 2 + 2 <= heap.last) {
      swap(&heap.data[i], &heap.data[i * 2 + 2]);
      swap(&heap.index[i], &heap.index[i * 2 + 2]);
      i = i * 2 + 2;
    }
    else {
      break;
    }
  }

  return min_idx;
}

int main(void)
{
  int n;
  scanf("%d", &n);

  init();

  int a[n];
  for(int i = 0; i < n; i++) {
    scanf("%d", &a[i]);

    insert(i, a[i]);
  }

  for(int i = 0; i < n; i++) {
    printf("%d ", deletemin() + 1);
  }
  printf("\n");

  return 0;
}