#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;

	int n;
	cin >> n;

	vector<int> a(n + 1), b(n + 1), swapped(n + 1, 0);
	vector<int> ans;
	priority_queue<int, vector<int>, greater<int>> pq;

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[a[i]] = i;
		pq.push(a[i]);
	}
	swapped[0] = 1;

	while (pq.size())
	{
		int k = pq.top();
		pq.pop();
		int pos = b[k];
		while (pos - 1 > 0 && swapped[pos - 1] == 0 && a[pos - 1] > k)
		{
			ans.push_back(pos - 1);
			b[k] = pos-1;
			int l = a[pos-1];
			b[l] = pos;
			swap(a[pos], a[pos-1]);
			swapped[pos-1] = 1;
			pos--;
		}
	}

	// for (auto x : a)
	// 	cout << x << endl;

	//cout << ans.size() << " " << n << endl;

	if (is_sorted(all(a)) && ans.size() == n-1)
	{
		for (auto x : ans)
			cout << x << endl;
	}
	else
		cout << -1 << endl;

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P.at(i);
    ll s = 1;
    vector<ll> ans(0);
    bool diff = false;
    rep(i, N){
        if(P.at(i) == s){
            if(i == s-1){
                cout << -1 << endl;
                return 0;
            }
            rep(j, i-s+1){
                ans.push_back(i-j);
            }
            s = i+1;
            diff = false;
        }
        else if(P.at(i) == i+1){
            cout << -1 << endl;
            return 0;
        }
        else if(P.at(i) != i+2 && !diff){
            diff = true;
        }
        else if(P.at(i) != i+1 && diff){
            cout << -1 << endl;
            return 0;
        }
    }
    if(sz(ans) != N-1){
        cout << -1 << endl;
        return 0;
    }
    rep(i, N-1){
        cout << ans.at(i) << endl;
    }
}