#include <bits/stdc++.h>

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/* Lazy Segment Tree -----------*/
template <typename M>
class LazySegmentTree {
    using F = std::function<M(M, M)>;
    using G = std::function<M(M, int)>;
private:
    int n, h;
    std::vector<M> t, d;
    const F func;
    const G func2;
    const M M_init;
    inline void calc(int p, int length) {
        if(d[p] == M_init) t[p] = func(t[p<<1], t[p<<1|1]);
        else t[p] = func2(d[p], length);
    }
    inline void apply(int p, M value, int length) {
//        t[p] = func2(value, length);  // 区間更新バージョン
        t[p] += func2(value, length);  // 区間加算バージョン
        if(p < n) d[p] = value;
    }
    void _build_(int l, int r) {
        int length = 2;
        for(l += n, r += n-1; l > 1; length <<= 1) {
            l >>= 1; r >>= 1;
            for(int i = r; i >= l; --i) calc(i, length);
        }
    }
    void push(int l, int r) {
        int s = h, length = 1 << (h-1);
        for(l += n, r += n-1; s > 0; --s, length >>= 1) {
            for(int i = (l >> s); i <= (r >> s); ++i) if(d[i] != M_init) {
                    apply(i<<1, d[i], length);
                    apply(i<<1|1, d[i], length);
                    d[i] = M_init;
                }
        }
    }
public:
    // constructor
    LazySegmentTree(int N,F Combiner, G Func_for_segment, M M_init):
            n(N), func(Combiner), func2(Func_for_segment), M_init(M_init)
    {
        h = 0; int m = 1; while(m <= n) {m <<= 1; ++h;}
        t.assign(2*n, M_init);
        d.assign(n, M_init);
    }
    // set value at position p
    void set(int &p, const M &value) {t[p+n] = value;}
    // build
    void build() { _build_(0,n); }

    void modify(int l, int r, M value) {  // update value in [l, r)
        if(value == M_init) return;
        push(l, l+1);
        push(r-1, r);
        bool canl = false, canr = false;
        int length = 1;
        for(l += n, r += n; l < r; l >>= 1, r >>= 1, length <<= 1) {
            if(canl) calc(l-1, length);
            if(canr) calc(r, length);
            if(l & 1) apply(l++, value, length), canl = true;
            if(r & 1) apply(--r, value, length), canr = true;
        }
        for(--l; r > 0; l >>= 1, r >>= 1, length <<= 1) {
            if(canl) calc(l, length);
            if(canr && (!canl || l != r)) calc(r, length);
        }
    }

    M query(int l, int r) {  // reply to query in [l, r)
        push(l, l+1);
        push(r-1, r);
        M resl = M_init, resr = M_init;
        for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if(l & 1) resl = func(resl, t[l++]);
            if(r & 1) resr = func(t[--r], resr);
        }
        return func(resl, resr);
    }
    M operator[](int &k) { return query(k, k+1); }
};

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    /**
     * n回の操作ではn個の要素からなる数列ができる。
     * iが大きい方から調べる。
     * i = n:
     *     j <= iであるようなjで、element == indexが成立してるものを選ぶ
     *     ->削除
     */
    i32 n; cin >> n;
    vec<i32> b(n);
    rep(i,n) cin >> b[i];
    LazySegmentTree<i32> indexes(n+1, [](i32 a, i32 b){ return a+b;}, [](i32 p, int k){ return p*k;}, 0);
    rep(i,n+1) indexes.set(i, i+1);
    indexes.build();
    vec<bool> seen(n);
//    rep(i,n) cout << indexes[i] << (i==n-1 ? '\n' : ' ');  // Debug

    stack<i32> st;
    rep(i,n) {
        for(int j = n-1; j >= 0; --j) {
            if(b[j] == indexes[j] && !seen[j]) {
                st.push(b[j]);
                seen[j] = true;
                indexes.modify(j+1, n, -1);
                break;
            }
        }
//    rep(i,n) cout << indexes[i] << (i==n-1 ? '\n' : ' ');  // Debug
    }

    for(auto bl : seen) if(!bl) {
        cout << -1 << '\n';
        return 0;
    }

    while (st.size()) {
        cout << st.top() << '\n';
        st.pop();
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256