#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+100;
int n;
struct SplayTree
{
int pre[maxn],ch[maxn][2],size[maxn],rev[maxn],root;
void Update_Rev(int r)
{
rev[r]^=1;
}
void Push_Down(int r)
{
if(rev[r])
{
rev[ch[r][0]]^=1;
rev[ch[r][1]]^=1;
swap(ch[r][0],ch[r][1]);
rev[r]=0;
}
}
void Push_Up(int r)
{
size[r]=1+size[ch[r][0]]+size[ch[r][1]];
}
void Rotate(int x,int kind)
{
int y=pre[x];
Push_Down(y);
Push_Down(x);
ch[y][kind^1]=ch[x][kind];
pre[ch[x][kind]]=y;
if(pre[y]) ch[pre[y]][ch[pre[y]][1]==y] = x;
pre[x]=pre[y];
ch[x][kind]=y;
pre[y]=x;
Push_Up(y);
}
void Splay(int r,int goal)
{
Push_Down(r);
while(pre[r]!=goal)
{
if(pre[pre[r]]==goal)
{
Push_Down(pre[r]);
Push_Down(r);
Rotate(r,ch[pre[r]][0]==r);
}
else
{
Push_Down(pre[pre[r]]);
Push_Down(pre[r]);
Push_Down(r);
int y=pre[r];
int kind=ch[pre[y]][0]==y;
if(ch[y][kind]==r)
{
Rotate(r,kind^1);
Rotate(r,kind);
}
else
{
Rotate(y,kind);
Rotate(r,kind);
}
}
}
Push_Up(r);
if(goal==0) root=r;
}
void New_Node(int &r,int fa,int k)
{
r=k;//结点=下标
pre[r]=fa;
ch[r][0]=ch[r][1]=rev[r]=0;
size[r]=1;
}
void Build(int &x,int l,int r,int fa)
{
if(l>r)return ;
int mid=(l+r)>>1;
New_Node(x,fa,mid);
Build(ch[x][0],l,mid-1,x);
Build(ch[x][1],mid+1,r,x);
Push_Up(x);
}
void Init()
{
root=0;
size[root]=0;
Build(root,1,n,0);//无须先建2个节点
}
int Get_Max(int r)
{
Push_Down(r);
while(ch[r][1])
{
r=ch[r][1];
Push_Down(r);
}
return r;
}
void Remove()
{
if(ch[root][0]==0)
{
root=ch[root][1];
pre[root]=0;
}
else
{
int m=Get_Max(ch[root][0]);
Splay(m,root);
ch[m][1]=ch[root][1];
pre[ch[root][1]]=m;
root=m;
pre[m]=0;
Push_Up(root);
}
}
}st;
struct Node
{
int num;
int id;
bool operator<(const Node&b)const
{
if(num==b.num) return id<b.id;
return num<b.num;
}
}nodes[maxn];
int main()
{
while(scanf("%d",&n)==1&&n)
{
st.Init();
for(int i=1;i<=n;i++)
{
scanf("%d",&nodes[i].num);
nodes[i].id=i;
}
sort(nodes+1,nodes+1+n);
for(int i=1;i<n;i++)
{
st.Splay(nodes[i].id,0);
st.Update_Rev(st.ch[st.root][0]);
printf("%d ",st.size[st.ch[st.root][0]]+i);
st.Remove();
}
printf("%d\n",n);
}
}
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+100;
int n;
struct SplayTree
{
int pre[maxn],ch[maxn][2],size[maxn],rev[maxn],root;
void Update_Rev(int r)
{
rev[r]^=1;
}
void Push_Down(int r)
{
if(rev[r])
{
rev[ch[r][0]]^=1;
rev[ch[r][1]]^=1;
swap(ch[r][0],ch[r][1]);
rev[r]=0;
}
}
void Push_Up(int r)
{
size[r]=1+size[ch[r][0]]+size[ch[r][1]];
}
void Rotate(int x,int kind)
{
int y=pre[x];
Push_Down(y);
Push_Down(x);
ch[y][kind^1]=ch[x][kind];
pre[ch[x][kind]]=y;
if(pre[y]) ch[pre[y]][ch[pre[y]][1]==y] = x;
pre[x]=pre[y];
ch[x][kind]=y;
pre[y]=x;
Push_Up(y);
}
void Splay(int r,int goal)
{
Push_Down(r);
while(pre[r]!=goal)
{
if(pre[pre[r]]==goal)
{
Push_Down(pre[r]);
Push_Down(r);
Rotate(r,ch[pre[r]][0]==r);
}
else
{
Push_Down(pre[pre[r]]);
Push_Down(pre[r]);
Push_Down(r);
int y=pre[r];
int kind=ch[pre[y]][0]==y;
if(ch[y][kind]==r)
{
Rotate(r,kind^1);
Rotate(r,kind);
}
else
{
Rotate(y,kind);
Rotate(r,kind);
}
}
}
Push_Up(r);
if(goal==0) root=r;
}
void New_Node(int &r,int fa,int k)
{
r=k;//结点=下标
pre[r]=fa;
ch[r][0]=ch[r][1]=rev[r]=0;
size[r]=1;
}
void Build(int &x,int l,int r,int fa)
{
if(l>r)return ;
int mid=(l+r)>>1;
New_Node(x,fa,mid);
Build(ch[x][0],l,mid-1,x);
Build(ch[x][1],mid+1,r,x);
Push_Up(x);
}
void Init()
{
root=0;
size[root]=0;
Build(root,1,n,0);//无须先建2个节点
}
int Get_Max(int r)
{
Push_Down(r);
while(ch[r][1])
{
r=ch[r][1];
Push_Down(r);
}
return r;
}
void Remove()
{
if(ch[root][0]==0)
{
root=ch[root][1];
pre[root]=0;
}
else
{
int m=Get_Max(ch[root][0]);
Splay(m,root);
ch[m][1]=ch[root][1];
pre[ch[root][1]]=m;
root=m;
pre[m]=0;
Push_Up(root);
}
}
}st;
struct Node
{
int num;
int id;
bool operator<(const Node&b)const
{
if(num==b.num) return id<b.id;
return num<b.num;
}
}nodes[maxn];
int main()
{
while(scanf("%d",&n)==1&&n)
{
st.Init();
for(int i=1;i<=n;i++)
{
scanf("%d",&nodes[i].num);
nodes[i].id=i;
}
sort(nodes+1,nodes+1+n);
for(int i=1;i<n;i++)
{
st.Splay(nodes[i].id,0);
st.Update_Rev(st.ch[st.root][0]);
printf("%d ",st.size[st.ch[st.root][0]]+i);
st.Remove();
}
printf("%d\n",n);
}
}