#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 6e5 + 100;
struct re{
ll x, y;
ll pre, nex;
};
ll n, h = -1;
int sum[N];
re v[N];
void erase_list(ll x){
if (v[x].pre == 0) h = v[x].nex;
v[v[x].pre].nex = v[x].nex, v[v[x].nex].pre = v[x].pre;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
int x, cnt = 0;
for (int i = 1; i <= n; i ++) {
cin >> x;
if (i != n){
v[++ cnt].x = x, v[cnt].y = i, v[cnt].pre = i - 1, v[cnt].nex = i + 1;
if (i == 1) h = i;
}else
v[++ cnt].x = x, v[cnt].y = i, v[cnt].pre = i - 1, v[cnt].nex = -1;
// cout << i << ": " << v[cnt].pre << " & " << v[cnt].nex << "\n";
}
bool b = 0;
while (cnt){
ll o = -1, b = 0;
for (ll i = h; i != -1;){
if (v[i].x != o){
cnt --;
o = v[i].x;
cout << i << " ";
erase_list(i);
b = 1;
// cout << "////////////////////////////////////////////////////////////\n";
// for (int j = h; v[j].nex != -1; j = v[j].nex){
// cout << v[j].y << ": " << v[j].pre << " & " << v[j].nex << "\n";
// }
// cout << "------------------------------------------------------------\n";
}else i = v[i].nex;
}
if (b)
cout << "\n";
}
return 0;
}
指点迷津