/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <chrono>

using namespace std;
using namespace std::chrono;

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"

#define sq(x)           (x*x)

#define vll             vector<ll>
#define rev(v)          reverse(v.begin(),v.end())
#define srt(v)          sort(v.begin(),v.end())
#define grtsrt(v)       sort(v.begin(),v.end(),greater<int>())
#define mnv(v)          *min_element(v.begin(),v.end())
#define mxv(v)          *max_element(v.begin(),v.end())
#define all(v)          v.begin(),v.end()

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const ll M= 1e8;

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes-----------------------------------------------//
ll MAXN=100000;
vector<ll> fact(MAXN);
void sieve_of_erantothenes()
{
    fact[1] = 1;
    for (ll i = 2; i <= MAXN; i++)
        fact[i] = i;
    for (ll i = 4; i <= MAXN; i += 2)
        fact[i] = 2;
    for (ll i = 3; i * i <= MAXN; i++){
        if (fact[i] == i){
            for (ll j = i * i; j <= MAXN; j += i)
                if (fact[j] == j)
                    fact[j] = i;
        }
    }
}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}
//-----------------------------------------------solve-----------------------------------------------------//
void solve(){
    ll n;cin>>n;
    for(ll i=1;i<=n;i++){
        cout<<floor(log2(i))+1<<" ";
    }
    cout<<endl;
}

int main(){
    Fas;
//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();
    
    return 0;
}

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll icnt(vector<ll> &arr)
{
    ll n = arr.size();
    ordered_set os;
    ll ans = 0;
    for(ll i=n-1;i>-1;i--)
    {
        ans+=os.order_of_key(arr[i]);
        os.insert(arr[i]);
    }
    return ans;
}

int main()
{
  FAST/**/
  
  ll n;
  cin>>n;
  
  vector<ll> arr(n);
  rep(n)
        cin>>arr[i], arr[i]--;
  
  if(icnt(arr) != n-1)
  {
      cout<<-1;
      return 0;
  }
  
  set<pii> op;
  vector<ll> ins;
  bool pos = 1;
  for(ll i=0;i<n;i++)
  {
      if(arr[i]<i)
      {
          for(ll j=i;j>arr[j];j--)
          {
              if(op.find(mp(j-1,j)) != op.end())
              {
                  pos = 0;
                  break;
              }
              
              op.insert(mp(j-1,j));
              ins.pb(j);
              swap(arr[j],arr[j-1]);
          }
          if(pos == 0)
                break;
      }
  }
  rep(n)
        if(arr[i] != i)
            pos = 0;
  
  //cout<<op.size()<<'\n';
  if(op.size() != n-1 || pos == 0)
        cout<<-1<<'\n';
  else
  {
      rep(n-1)
            cout<<ins[i]<<"\n";
  }
  
  
  
  return 0;
}
   
   
 