#include<bits/stdc++.h>
using namespace std;
struct P{
int l,r,z;
};
queue<P>q,p;
int n,a[200010];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=n;i++){
int j=i;
while(a[j]==a[i]&&j<=n)j++;
q.push({i,j-1,a[i]});
i=j-1;
}
int c=n;
while(c){
int sy=-1;
while(!q.empty()){
P v=q.front();
q.pop();
if(v.z==sy){
p.push({v.l,v.r,v.z});
continue;
}
printf("%d ",v.l);
if(v.l<v.r)p.push({v.l+1,v.r,v.z});
c--;
sy=v.z;
}
printf("\n");
while(!p.empty()){
P v=p.front();
p.pop();
q.push(v);
}
}
return 0;
}