#include<bits/stdc++.h>
using namespace std;
int n;
struct re {
int val;
int cnt;
string idx;
};
vector<re> v;
string s;
inline string change(int i) {
string s;
while(i) {
char c=i%10+'0';
s=c+s;
i/=10;
}
return s;
}
inline int get(string s) {
for(int i=0; i<s.size(); i++) {
if(s[i]==' ') return i;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
int tot=0;
int tmp;
for(int i=1; i<=n; i++) {
int x;
cin>>x;
tot++;
if(tmp!=x&&i!=1) {
v.push_back({tmp,tot-1,s});
s="";
tot=1;
}
if(i==n) {
s=s+change(i)+' ';
v.push_back({tmp,tot,s});
}
tmp=x;
s=s+change(i)+' ';
}
while(v.size()) {
for(int i=0; i<v.size(); i++) {
bool p=0;
v[i].cnt--;
int ws=get(v[i].idx);
for(int j=0; j<ws; j++) cout<<v[i].idx[j];
cout<<" ";
v[i].idx.erase(0,ws+1);
if(v[i].cnt==0) {
v.erase(v.begin()+i);
if(i!=v.size()&&i!=0) {
v[i].cnt--;
v[i-1].cnt+=v[i].cnt;
int w=get(v[i].idx);
for(int j=0; j<w; j++)
cout<<v[i].idx[j];
cout<<" ";
v[i].idx.erase(0,w+1);
v[i-1].idx+=v[i].idx;
v.erase(v.begin()+i);
}
i--;
}
}
cout<<endl;
}
return 0;
}