#include <bits/stdc++.h>
#define MAXN 200'100
using namespace std;
int a[MAXN], b[MAXN];
int main()
{
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 0; i<n; ++i)
cin >> a[i], b[i] = a[i];
sort(b,b+n,std::greater<int>());
int cur_size = 0;
set<int> s;
for (int i = 0; i<n; ++i)
{
s.insert(a[i]);
while (s.find(b[cur_size]) != s.end())
cout << b[cur_size++] << ' ';
cout << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIE1BWE4gMjAwJzEwMAoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBhW01BWE5dLCBiW01BWE5dOwoKaW50IG1haW4oKQp7CgljaW4udGllKE5VTEwpOwoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgkKICAgIGludCBuOwogICAgY2luID4+IG47CgogICAgZm9yIChpbnQgaSA9IDA7IGk8bjsgKytpKQogICAgICAgIGNpbiA+PiBhW2ldLCBiW2ldID0gYVtpXTsKICAgIHNvcnQoYixiK24sc3RkOjpncmVhdGVyPGludD4oKSk7CiAgICBpbnQgY3VyX3NpemUgPSAwOwogICAgc2V0PGludD4gczsKICAgIGZvciAoaW50IGkgPSAwOyBpPG47ICsraSkKICAgIHsKICAgICAgICBzLmluc2VydChhW2ldKTsKICAgICAgICB3aGlsZSAocy5maW5kKGJbY3VyX3NpemVdKSAhPSBzLmVuZCgpKQogICAgICAgICAgICBjb3V0IDw8IGJbY3VyX3NpemUrK10gPDwgJyAnOwogICAgICAgIGNvdXQgPDwgZW5kbDsKICAgIH0KfQ==