#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 200010;
int n;
struct node{
int th;
int pos;
};
vector<node> vec[N];
vector<node> New;
int tot = 1;
int a[N];
int main(){
cin >> n;
for(int i = 1;i <= n;i++) scanf("%d" , &a[i]);
a[0] = a[1];
for(int i = 1;i <= n;i++){
New.push_back({a[i] , i});
if(a[i] == a[i - 1]) vec[tot].push_back({a[i] , i});
else vec[++tot].push_back({a[i] , i});
}
int f = n;
while(f){
vector<vector<node> :: iterator> Pos;
for(int i = 1;i <= tot;i++){
if(!vec[i].empty()){
printf("%d " , vec[i].front().pos); f--;
Pos.push_back(vec[i].begin());
vec[i].erase(vec[i].begin());
}
}
cout << endl;
for(auto i : Pos) New.erase(i);
for(int i = 1;i <= tot;i++) vec[i].clear();
tot = 1;
if(!New.empty()) vec[tot].push_back(New[0]);
for(int i = 1;i < New.size();i++){
if(New[i].th == New[i - 1].th) vec[tot].push_back(New[i]);
else vec[++tot].push_back(New[i]);
}
}
return 0;
}