#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    int a[n + 5], i, pos = n - 1;
    for (i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    vector<int> ans;
    for (i = n - 1; i >= 1; --i) {
        if (a[i] == i) {
            break;
        }
        if (a[i] < i) {
            continue;
        }
        if (a[i] - 1 == pos) {
            for (int j = i; j <= pos; ++j) {
                swap(a[j], a[j + 1]);
                ans.push_back(j);
            }
            pos = i - 1;
        } else {
            break;
        }
    }
    for (i = 1; i <= n; ++i) {
        if (a[i] != i) {
            break;
        }
    }
    if (i == n + 1 and pos == 0) {
        for (i = 0; i < n - 1; ++i) {
            cout << ans[i] << "\n";
        }
    } else {
        cout << "-1";
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;

int main(void)
{
    int N;
    cin >> N;
    vector<int> p(N,0);
    vector<bool> used(N,false);
    vector<int> ans;

    rep(i, N){
        cin >> p[i];
        --p[i];
    } 
    int cc = 0;
    for(int i = 0; i < N-1; ++i)
    {
        while(1)
        {
            if((p[cc]-cc)*(p[cc+1]-cc-1) < 0)
            {
                if(used[cc])
                {
                    cout << -1 << endl;
                    return 0;
                }
                ans.push_back(cc);
                used[cc] = false;
                iter_swap(p.begin()+cc, p.begin()+cc+1);
                --cc;
                break;
            }
            else
            {
                ++cc;
                if(cc == N-1)
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    bool ok = true;
    rep(i,N)
    {
        if(i != p[i]) ok = false;
    }
    if(ok) rep(i, N-1) cout << ans[i]+1 << endl;
    else cout << -1 << endl;

    return 0;
}
