#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll dmod(ll x){
    return ((x+mod)%mod);
}
ll modular_power(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1)ans=dmod(ans*x);
        y/=2;
        x=dmod(x*x);
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    int P[n+1];
    for(int i=1;i<=n;i++)cin>>P[i];
    set <int> st;
    for(int i=1;i<n;i++)st.insert(i);
    set <int> q;
    for(int i=1;i<n;i++)if(P[i]>i && P[i+1]<i+1)q.insert(i);
    vector <int> ans;
    while(!q.empty()){
        int x=*(q.begin());
        st.erase(x);
        swap(P[x],P[x+1]);
        q.erase(x);
        ans.push_back(x);
        if(x-1>0 && P[x-1]>x-1 && P[x]<x && st.count(x-1))q.insert(x-1);
        else if(q.count(x-1))q.erase(x-1);
        if(x+1<n && P[x+1]>x+1 && P[x+2]<x+2 && st.count(x+1))q.insert(x+1);
        else if(q.count(x+1))q.erase(x+1);
    }
    bool flag=true;
    for(int i=1;i<=n;i++)if(P[i]!=i)flag=false;
    if(flag && st.size()==0)for(auto it:ans)cout<<it<<endl;
    else cout<<-1;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n;
    cin >> n;
    vll p(n), a(n);
    REP(i, n) {
        cin >> p[i];
        p[i]--;
        a[i] = i - p[i];
    }
    vector<P> pos;
    ll sum = 0;
    REP(i, n) {
        if (a[i] > 0) {
            pos.push_back(P{i, a[i]});
            sum += a[i];
        }
    }
    if (sum != n - 1) {
        cout << -1 << endl;
        return 0;
    }
    vll res;
    vll used(n);
    for (auto x : pos) {
        ll tmp = x.first - 1;
        REP(i, x.second) {
            if (tmp == -1) {
                cout << -1 << endl;
                return 0;
            }
            if (used[tmp]) {
                cout << -1 << endl;
                return 0;
            }
            used[tmp] = 1;
            res.push_back(tmp);
            tmp--;
        }
    }
    vll ideal(n);
    iota(ALL(ideal), 0);
    REP(i, n - 1) {
        swap(p[res[i]], p[res[i] + 1]);
    }
    if (p == ideal) {
        REP(i, n - 1) cout << res[i] + 1 << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}