/*
         Crimson coagulates
         Severed head bouquet
         Body incomplete
         Sealer of your fate

         Crimson calligraphy
         Written on the trees
         Creature from the grave
         Headless and hellbent for me!
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define mod  1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)

vector<vector<int>> dp;
vector<int> ht,dpt;

const int N = 1000004;
int bit[N];
void update(int i,int x)
{
         if(i>=N)return;
         bit[i] += x;
         update(i+(i&(-i)),x);
}
int get(int x)
{
         if(x==0)return 0;
         return bit[x] + get(x-(x&(-x)));
}
signed main()
{
         int n;
         cin>>n;
         int a[n+1];
         for(int i = 1 ; i < n+1 ; i++)cin>>a[i];
         set<int> s;
         vector<int> ans;
         int ix[n+1];
         for(int i = 1 ; i <= n ; i++)ix[a[i]] = i;
         memset(bit,0,sizeof bit);
         for(int i = 1 ; i <= n ; i++){
                  int curr = ix[i] + get(N-1)-get(ix[i]);
                  update(ix[i],1);
                  int j = curr;

                  while(i != j)
                  {
                           if(s.find(j-1)!=s.end()){cout<<-1<<endl;return 0;}
                           s.insert(j-1);
                           //swap(a[j],a[j-1]);
                           ans.push_back(j-1);
                           j--;
                  }
         }
         if(ans.size()!=n-1){
                  cout<<-1<<endl;
                  return 0;
         }
         for(int i : ans)cout<<i<<endl;
//         main();

}

#include <bits/stdc++.h>

using namespace std;
#define N 1000010
#define ll long long
ll n, a[N], rk[N], vis[N], ans[N];

inline void solve() {
    scanf("%lld", &n);
    int flag = 1, r = 0;
    for (int i = 1; i <= n; ++i)scanf("%lld", &a[i]), rk[a[i]] = i;
    for (int i = 1; i <= n; ++i) {
        if (!flag)break;
        for (int j = rk[i]; j > i; --j)
            if (!vis[j]) {
                vis[j] = 1, ++rk[a[j - 1]], --rk[a[j]], swap(a[j], a[j - 1]);
                ans[++r] = j - 1;
            } else {
                flag = 0;
                break;
            }
    }
    if (flag && r == n - 1) {
        for (int i = 1; i <= r; ++i)printf("%lld\n", ans[i]);
    } else puts("-1");
}

int main() {
    int T = 1;
    //scanf("%d", &T);
    while (T--)solve();
}
