/*
TASK:fsort
LANG:C++
*/
#include <iostream>
#include <algorithm>
using namespace std;
int in[1001],sorted[1001],n,k[2002],kbr=0;
void input()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>in[i];
sorted[i]=in[i];
}
sort(sorted,sorted+n);
}
void output()
{
for(int i=0;i<kbr-2;i++)
cout<<k[i]<<" ";
cout<<"\n";
}
int maxe(int a,bool b)
{
    int me=0,mep;
    if(b==1)
    {
         for(int i=0;i<=a;i++)
         if(in[i]>me)
         {
          me=in[i];
          mep=i;
         }
    }
    else 
         for(int i=0;i<a;i++)
         if(sorted[i]>me)
         {
          me=sorted[i];
          mep=i;
         }
    return mep;
}
void swappy(int a,int b)
{
in[a]=in[a]+in[b];
in[b]=in[a]-in[b];
in[a]=in[a]-in[b];
}
void swap(int a)
{
 for(int i=0;i<a/2;i++)
  swappy(i,a-i);
   
}
bool check()
{  int i;
for(i=0;i<n;i++)
if(in[i]!=sorted[i])return 0;
//cout<<in[i]<<sorted[i];
else return 1;                   
}
void chief()
{
    for(int i=n;i>1;i--)
    if(check()==1)output();
    else {if(maxe(i,1)!=maxe(i,0))
    {k[kbr++]=maxe(i,1)+1;
    maxe(i,1);
    swap(maxe(i,1));
    if(maxe(i,1)!=maxe(i,0))
    {k[kbr++]=maxe(i,0)+1;
    swap(maxe(i,0));
    
     }
    
     }    }
    
    
    


}
int main()
{ 
    input();
    chief();//LopiTo
    output();

return 0;
}
