#include <cstdio>
#include <list>
using namespace std;
struct Node {
int Type, Id;
};
struct Solution {
int N;
list<list<Node>> L;
void Solve() {
scanf("%d", &N);
int last = -1;
for (int i = 0; i < N; ++i) {
int x;
scanf("%d", &x);
if (x != last) L.emplace_back();
L.back().emplace_back(Node{x, i});
last = x;
}
while (!L.empty()) {
list<list<Node>> newL;
bool head = true;
for (auto& i : L) {
if (!head) printf(" ");
head = false;
printf("%d", 1 + i.front().Id);
i.pop_front();
if (!i.empty()) {
if (newL.empty() ||
newL.back().front().Type != i.front().Type) {
newL.emplace_back(move(i));
} else {
newL.back().splice(newL.back().end(), move(i));
}
}
}
L = move(newL);
printf("\n");
}
}
};
int main() {
Solution().Solve();
return 0;
}