#include<iostream>
#include<cstdio>
using namespace std;
struct note{
bool used;
bool f;
int l,r;
}h[200005];
int n,a[200005],qwe[2000000],s=1,num,w,t;
void d(){
num=s;w=-1;
do{
w=-1;t=0;
for(int i=1;i<=s;i++){
if(h[i].used==true){
if(w==-1)w=!h[i].f;
if(h[i].f!=w){
w=h[i].f;
qwe[t]=h[i].l;
t++;
h[i].l++;
if(h[i].l>h[i].r){
num--;
h[i].used=false;
}
}
}
}
for(int i=0;i<t;i++)
{
cout<<qwe[i];
if(i<t-1)cout<<' ';
}
printf("\n");
}while(num>0);
}
int main(){
//freopen("fruit.in","r",stdin);
//freopen("fruit.out","w",stdout);
scanf("%d%d",&n,&a[1]);
h[1].l=1;h[1].used=true;h[1].f=a[1];
w=a[1];
for(int i=2;i<=n;i++){
scanf("%d",&a[i]);
if(a[i]!=w){
w=a[i];
h[s].r=i-1;
s++;
h[s].l=i;
h[s].used=true;
h[s].f=w;
}
}h[s].r=n;h[s].used=true;
d();
return 0;
}