#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

ll inf = 1e9+7;

template <typename T>
T bfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    queue<T> q;
    q.emplace(source);
    vis.at(source) = true;
    while(!q.empty())
    {
        T top = q.front();
        q.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            q.emplace(tem);
            element_num++;
        }
    }
    return element_num;
}

template <typename T>
T dfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    stack<T> s;
    s.push(source);
    vis.at(source) = true;
    while(!s.empty())
    {
        T top = s.top();
        s.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            s.emplace(top);
            s.emplace(tem);
            element_num++;
            break;
        }
    }
    return element_num;
}

template <typename T>
vector<vector<T> > input_graph(T array_num, T edge_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_graph function can only be in type \"int\" or \"long long int\"!\n");
    vector<vector<T> > a(array_num, vector<T>());
    for(T i = 0; i < edge_num; i++)
    {
        T d1, d2;
        cin >> d1 >> d2;
        a.at(d1-1).emplace_back(d2-1);
        a.at(d2-1).emplace_back(d1-1);
    }

    return a;
}

template <typename T>
vector<T> input_vector(T array_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_vector function can only be in type \"int\" or \"long long int\"!\n");
    vector<T> a(array_num, 0);
    for(T i = 0; i < array_num; i++)
    {
        cin >> a.at(i);
    }

    return a;
}



int main() {
    int n, k, d;
    cin >> n;
    vector<int> a(n, 0);
    bool is_false = false;
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if(a.at(i) > (i+1))
        {
            is_false = true;
        }
    }
    if(is_false)
    {
        cout << -1;
        return 0;
    }
    list<int> result;
    for(int i = 0; i < n; i++)
    {
        if(a.at(i) == 1)
        {
            result.push_back(1);
        }
    }
    for(int i = 1 ; i <= n; i++)
    {
        list<int>::iterator it = result.begin();
        for(int j = 0; j < i; j++)
        {
            ++it;
        }
        for(int j = n-1; j >= 0; j--)
        {
            if(a.at(j) == i+1)
            {
                result.insert(it, i+1);
            }
            if(a.at(j) < i+1)
            {
                ++it;
            }
        }

    }

    for(list<int>::iterator it = result.begin(); it != result.end(); ++it)
    {
        cout << *it <<endl;
    }

    return 0;
}


Measured memory_bytes: 256