#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> getSegmentTree(int n) {
    vector<int> segmentTree(4 * n, 0);
    int j = 0;
    for (int i = 0; i < n; i++) {
        segmentTree[i + n] = i + 1;
    }
    while (j < n) {
        for (int i = 0; i < n; i++) {
            segmentTree[j] = min(segmentTree[i + n], segmentTree[i + n + 1]);
            j++;
        }
    }
    return segmentTree;
}

int findFirstSmaller(vector<int>& segmentTree, int value) {
    int j = 0;
    int i = 0;
    while (i < segmentTree.size() / 2) {
        if (segmentTree[i] <= value) {
            i = 2 * i + 2;
        } else {
            i = 2 * i + 1;
        }
        j = i / 2;
    }
    return segmentTree[j];
}

vector<int> getArray(vector<int>& segmentTree, int n) {
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        arr[i] = findFirstSmaller(segmentTree, i + 1);
    }
    return arr;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> segmentTree = getSegmentTree(n);
    for (int i = 0; i < n; i++) {
        if (a[i] != segmentTree[i + n]) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> arr = getArray(segmentTree, n);
    for (int i = 0; i < n; i++) {
        cout << arr[i] << " ";
    }
    return 0;
}
