#include <bits/stdc++.h>
using namespace std; 
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
#define TIME cerr<<"Time Taken:"<<(float)clock()/CLOCKS_PER_SEC*1000<<"ms"<<endl
//  When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef somujena
    freopen("/home/somujena/competitive/input.txt", "r", stdin);
    freopen("/home/somujena/competitive/output.txt", "w", stdout);
    #endif
    // code goes here
    LL t=1;//cin>>t;
    while(t--){
      LL n,i,j;cin>>n;
      LL a[n];
      fo(i,0,n) cin>>a[i];
      std::vector<LL> v;
      LL in=1,prev=0,f=1;
      fo(i,0,n){
        if(a[i]==in){
          if(i-1==prev){
            if(a[i]>a[i-1]) {f=0;break;}
            else{
              swap(a[i],a[i-1]);
              v.pb(i);
              if(a[i]-a[i-1]==1) {prev=i+1,in=a[i]+1;}
              else {prev=i;in=a[i-1]+1;}
            }
            continue;
          }
          if(i==prev){
            prev=i+1;
            in=a[i]+1;
            continue;
          }
          bool f1=1;
          if(a[prev]-in!=1) f1=0;
          fo(j,prev,i-2){
            if(a[j+1]-a[j]!=1) f1=0;//,cout<<j<<endl;
          }
          if(a[i-1]<a[i-2]) f1=0;
          if(!f1) f=0;//,cout<<i<<sp<<in<<endl;
          else{
            rfo(j,i,prev) swap(a[j],a[j-1]),v.pb(j);
            if(a[i]-a[i-1]!=1) {in=a[i-1]+1,prev=i;}
            else {in=a[i]+1,prev=i+1;}
          }
        }
      }
      if(v.size()!=n-1) f=0;
      if(!f) cout<<-1;
      else{
        for(auto x:v) cout<<x<<endl;
      }
    }
    TIME;
    return 0;
}
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
lli digits(lli n)
{
	lli cnt = 0;
	while(n)
	{
		cnt++;
		n = n / 10;
	}
	return cnt;
}
int main()
{
	lli i,j,t,n,sum,m,x1,x2,y1,y2,ans,num,a,b,c,d,cnt = 0,l,odd=0,even=0,diff,x,mini,k,maxi,y;
	cin >> n;
	for(i=1;;i++)
	{
		if(stoll(to_string(i) + to_string(i)) > n)
		{
			cout << i - 1;
			break;
		}
	}


	return 0;
}