#include<bits/stdc++.h>
using namespace std;
const int r=200010;
int n,m,t,hs,daa,x[r],xyg[r],st[r],gs[r],da[r];
map<int,map<int,int> >b;
int find(int hm)
{
if (gs[xyg[hm]]>0) return xyg[hm];
return xyg[hm]=find(xyg[hm]);
}
int main ()
{
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>x[i];x[i]++;
if (t!=x[i]||i==1)
{
t=x[i];hs++;
xyg[hs]=hs+1;
}
b[hs][++gs[hs]]=i;
}
gs[hs+1]=r;
for (int i=1;i<=hs;i++) st[i]=1;
while (0==0)
{
daa=0;t=0;
for (int i=1;i<=hs;i=find(i))
if (gs[i]>0&&(x[b[i][st[i]]]!=t||daa==0))
{
daa++;
da[daa]=b[i][st[i]];
b[i][st[i]]=0;
st[i]++;
gs[i]--;
t=x[da[daa]];
}
if (daa==0) break;
for (int i=1;i<=daa;i++) cout<<da[i]<<" ";
cout<<endl;
}
return 0;
}