#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
int a[101],flag[101];
void Exchange(int m)
{
int temp;
for(int i=0,j=m;i<j;i++,j--)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
int main()
{
int i,j;
int pos=0;
while(cin>>a[0])
{
int index = 1,step = 0;
while(getchar()==' ')
{
cin>>a[index++];
}
cout<<a[0];
for(i=1; i<index; i++)
cout<<" "<<a[i];
cout<<endl;
for(i=0;i<index;i++)
{
int max = -1;
for(j=index-i-1;j>=0;j--)
{
if(a[j]>max)
{
max = a[j];
pos = j;
}
}
if(pos != index-i-1)
{
if(pos)
{
Exchange(pos);
flag[step++] = index-pos;
}
Exchange(index-i-1);
flag[step++] = i+1;
}
}
if(step==0)
cout<<"0"<<endl;
else
{
for(i=0;i<step;i++)
cout<<flag[i]<<" ";
cout<<"0"<<endl;
}
}
return 0;
}