#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    vector<bool> m1(1000001);
    vector<bool> m2(1000001);
    forn(n) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    queue<int> q;
    queue<int> data;
    for(int i = 0; i < 1000000; i++) {
        if(m1[i] == false) data.push(i);
    }
    vector<int> answer(n);
    bool yes = true;
    int current = 0;
    int previous = 0;
    for(int i = 0; i < n; i++) {
        current = v[i] - 1;
        int kk = data.front();
        if(m2[kk] == true) data.pop();
        if(!q.empty()) {
            if(q.front() != v[i]) q.push(v[i]);
        }
        else {
            q.push(v[i]);
        }
        if(v[i] == 0) {
            int k = data.front();
            if(m2[k] == true) data.pop();
            k = data.front();
            data.pop();
            //cout << i << "-- >1\n";
            m2[k] = true;
            answer[i] = k;
        }
        else if(m2[v[i] - 1] == false) {
            m2[v[i] - 1] = true;
            int k = data.front();
            if(m2[k] == true) data.pop();
            //cout << i << "-- >2\n";
            answer[i] = v[i] - 1;
        }
        else {
            if(q.empty()) {
                //cout << i << "-- >3\n";
                int k = data.front();
                if(m2[k] == true) data.pop();
                k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                int k = q.front();
                if(k == v[i]) {
                    //cout << i << "-- >4\n";
                    if(m2[k] == true) data.pop();
                     k = data.front();
                    k = data.front();
                    data.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
                else {
                    //cout << i << "-- >5\n";
                    k = q.front();
                    if(m2[k] == true) data.pop();
                     k = data.front();
                    if(m2[k] == true) {
                        k = data.front();
                        data.pop();
                    }
                    q.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
            }
        }
        if(previous >= 0) {
            for(int j = current; j >= previous; j--) {
                if(m2[j] == false) yes = false;
            }
        }
        previous = current;
    }
    if(yes) {
        for(int i = 0; i < answer.size(); i++) {
            cout << answer[i] << " ";
        }
    }
    else {
        cout << -1;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    queue<int> data;
    vector<bool> m1(1000001);
    vector<int> v(n);
    vector<int> answer(n);
    unordered_map<int, bool> m2;
    m2[-1] = true;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    for(int i = 0; i < 1000001; i++) {
        if(m1[i] == false) data.push(i);
    }
    queue<int> q;
    int current = 0;
    int previous = 0;
    bool yes = true;
    for(int i = 0; i < n; i++) {
        if(q.empty()) {
           q.push(v[i]);
        }
        else {
            if(q.front() != v[i]) q.push(v[i]);
        }
        if(q.front() != v[i]) {
            m2[q.front()] = true;
            answer[i] = q.front();
            q.pop();
            continue;
        }
        if(m2[v[i] - 1] == false) {
            int k = q.front();
            if(k == v[i] - 1) {
                q.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
        }
        else {
            int k = data.front();
            m2[k] = true;
            data.pop();
            answer[i] = k;
        }
    }
    for(int i = 0; i < n; i++) {
        cout << answer[i] << " ";
    }
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    vector<bool> m1(1000001);
    vector<bool> m2(1000001);
    forn(n) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    queue<int> q;
    queue<int> data;
    for(int i = 0; i < 1000000; i++) {
        if(m1[i] == false) data.push(i);
    }
    vector<int> answer(n);
    bool yes = true;
    int current = 0;
    int previous = 0;
    for(int i = 0; i < n; i++) {
        current = v[i] - 1;
        if(!q.empty()) {
            if(q.front() != v[i]) q.push(v[i]);
        }
        else {
            q.push(v[i]);
        }
        if(v[i] == 0) {
            int k = data.front();
            data.pop();
            //cout << i << "-- >1\n";
            m2[k] = true;
            answer[i] = k;
        }
        else if(m2[v[i] - 1] == false) {
            m2[v[i] - 1] = true;
            data.pop();
            //cout << i << "-- >2\n";
            answer[i] = v[i] - 1;
        }
        else {
            if(q.empty()) {
                //cout << i << "-- >3\n";
                int k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                int k = q.front();
                if(k == v[i]) {
                    //cout << i << "-- >4\n";
                    k = data.front();
                    data.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
                else {
                    //cout << i << "-- >5\n";
                    k = q.front();
                    q.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
            }
        }
        if(previous >= 0) {
            for(int j = current; j >= previous; j--) {
                if(m2[j] == false) yes = false;
            }
        }
        previous = current;
    }
    if(yes) {
        for(int i = 0; i < answer.size(); i++) {
            cout << answer[i] << " ";
        }
    }
    else {
        cout << -1;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    vector<bool> m1(1000001);
    vector<bool> m2(1000001);
    forn(n) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    queue<int> q;
    queue<int> data;
    for(int i = 0; i < 1000000; i++) {
        if(m1[i] == false) data.push(i);
    }
    vector<int> answer(n);
    bool yes = true;
    int current = 0;
    int previous = 0;
    for(int i = 0; i < n; i++) {
        current = v[i] - 1;
        int kk = data.front();
        if(m2[kk] == true) data.pop();
        if(!q.empty()) {
            if(q.front() != v[i]) q.push(v[i]);
        }
        else {
            q.push(v[i]);
        }
        if(v[i] == 0) {
            int k = data.front();
            if(m2[k] == true) data.pop();
            k = data.front();
            data.pop();
            //cout << i << "-- >1\n";
            m2[k] = true;
            answer[i] = k;
        }
        else if(m2[v[i] - 1] == false) {
            m2[v[i] - 1] = true;
            int k = data.front();
            if(m2[k] == true) data.pop();
            //cout << i << "-- >2\n";
            answer[i] = v[i] - 1;
        }
        else {
            if(q.empty()) {
                //cout << i << "-- >3\n";
                int k = data.front();
                if(m2[k] == true) data.pop();
                k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                int k = q.front();
                if(k == v[i]) {
                    //cout << i << "-- >4\n";
                    if(m2[k] == true) data.pop();
                     k = data.front();
                    k = data.front();
                    data.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
                else {
                    //cout << i << "-- >5\n";
                    k = q.front();
                    if(m2[k] == true) data.pop();
                     k = data.front();
                    if(m2[k] == true) {
                        data.pop();
                        k = data.front();
                    }
                    q.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
            }
        }
        // if(previous >= 0) {
        //     for(int j = current; j >= previous; j--) {
        //         if(m2[j] == false) yes = false;
        //     }
        // }
        // previous = current;
    }
    if(yes) {
        for(int i = 0; i < answer.size(); i++) {
            cout << answer[i] << " ";
        }
    }
    else {
        cout << -1;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    vector<bool> m1(1000001);
    vector<bool> m2(1000001);
    forn(n) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    queue<int> q;
    queue<int> data;
    for(int i = 0; i < 1000000; i++) {
        if(m1[i] == false) data.push(i);
    }
    vector<int> answer(n);
    bool yes = true;
    int current = 0;
    int previous = 0;
    for(int i = 0; i < n; i++) {
        current = v[i] - 1;
        if(!q.empty()) {
            if(q.front() != v[i]) q.push(v[i]);
        }
        else {
            q.push(v[i]);
        }
        if(v[i] == 0) {
            int k = data.front();
            data.pop();
            //cout << i << "-- >1\n";
            m2[k] = true;
            answer[i] = k;
        }
        else if(m2[v[i] - 1] == false) {
            m2[v[i] - 1] = true;
            data.pop();
            //cout << i << "-- >2\n";
            answer[i] = v[i] - 1;
        }
        else {
            if(q.empty()) {
                //cout << i << "-- >3\n";
                int k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                int k = q.front();
                if(k == v[i]) {
                    //cout << i << "-- >4\n";
                    k = data.front();
                    data.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
                else {
                    //cout << i << "-- >5\n";
                    k = q.front();
                    q.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
            }
        }
        // if(previous >= 0) {
        //     for(int j = current; j >= previous; j--) {
        //         if(m2[j] == false) yes = false;
        //     }
        // }
        // previous = current;
    }
    if(yes) {
        for(int i = 0; i < answer.size(); i++) {
            cout << answer[i] << " ";
        }
    }
    else {
        cout << -1;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    vector<bool> m1(1000001);
    vector<bool> m2(1000001);
    forn(n) {
        cin >> v[i];
        m1[v[i]] = true;
    }
    queue<int> q;
    queue<int> data;
    for(int i = 0; i < 1000000; i++) {
        if(m1[i] == false) data.push(i);
    }
    vector<int> answer(n);
    bool yes = true;
    int current = 0;
    int previous = 0;
    for(int i = 0; i < n; i++) {
        current = v[i] - 1;
        if(!q.empty()) {
            if(q.front() != v[i]) q.push(v[i]);
        }
        else {
            q.push(v[i]);
        }
        if(v[i] == 0) {
            int k = data.front();
            data.pop();
            //cout << i << "-- >1\n";
            m2[k] = true;
            answer[i] = k;
        }
        else if(m2[v[i] - 1] == false) {
            m2[v[i] - 1] = true;
            int k = data.front();
            if(m2[k] == true) data.pop();
            //cout << i << "-- >2\n";
            answer[i] = v[i] - 1;
        }
        else {
            if(q.empty()) {
                //cout << i << "-- >3\n";
                int k = data.front();
                data.pop();
                m2[k] = true;
                answer[i] = k;
            }
            else {
                int k = q.front();
                if(k == v[i]) {
                    //cout << i << "-- >4\n";
                    k = data.front();
                    data.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
                else {
                    //cout << i << "-- >5\n";
                    k = q.front();
                    if(m2[k] == true) {
                        k = data.front();
                        data.pop();
                    }
                    q.pop();
                    m2[k] = true;
                    answer[i] = k;
                }
            }
        }
        if(previous >= 0) {
            for(int j = current; j >= previous; j--) {
                if(m2[j] == false) yes = false;
            }
        }
        previous = current;
    }
    if(yes) {
        for(int i = 0; i < answer.size(); i++) {
            cout << answer[i] << " ";
        }
    }
    else {
        cout << -1;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
            smallest++;
            for(int j=i-1;j>=0;j--)
            {
                if(smallest!=ar[i])ans[j]=smallest;
                else break;
                smallest++;
            }
        }
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
bool used[1000000];
bool ind[1000000];
int main()
{
    int n,j=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]!=ar[i-1]&&i!=0)
        {
            ans[i]=ar[i-1];
            used[ar[i-1]]=1;
            ind[i]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        //cout<<i<<"  "<<ind[i]<<endl;;
        if(!ind[i])
        {
            while(used[j])j++;
            ans[i]=j;
            used[j]=1;
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<< " ";
   cout<<endl;
   /* for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;*/

}


#include<bits/stdc++.h>
using namespace std;
bool used[1000000];
bool ind[1000000];
int main()
{
    int n,j=0;
    cin>>n;
    int ar[n],ans[n];
    cin>>ar[0];
    for(int i=1;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]!=ar[i-1])
        {
            ans[i]=ar[i-1];
            used[ar[i-1]]=1;
            ind[i]=1;
            used[ar[i]]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        //cout<<i<<"  "<<ind[i]<<endl;;
        if(!ind[i])
        {
            while(used[j])j++;
            ans[i]=j;
            used[j]=1;
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<< " ";
   cout<<endl;
   /* for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;*/

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1,z=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
            smallest++;
            for(int j=1;j<i;j--)
            {
                if(smallest!=ar[i])ans[j]=smallest;
                else break;
                smallest++;
            }
        }
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1,z=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
bool used[1000000];
bool ind[1000000];
int main()
{
    int n,j=0,z=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]==0)z++;
        if(ar[i]!=ar[i-1]&&i!=0)
        {
            ans[i]=ar[i-1];
            used[ar[i-1]]=1;
            ind[i]=1;
            used[ar[i]]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        //cout<<i<<"  "<<ind[i]<<endl;;
        if(!ind[i])
        {
            while(used[j]==1||j==ar[i])j++;
            ans[i]=j;
            used[j]=1;
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<< " ";
   cout<<endl;
   /* for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;*/

}


#include<bits/stdc++.h>
using namespace std;
bool used[1000000];
bool ind[1000000];
int main()
{
    int n,j=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]!=ar[i-1]&&i!=0)
        {
            ans[i]=ar[i-1];
            used[ar[i-1]]=1;
            ind[i]=1;
            used[ar[i]]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        //cout<<i<<"  "<<ind[i]<<endl;;
        if(!ind[i])
        {
            while(used[j])j++;
            ans[i]=j;
            used[j]=1;
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<< " ";
   cout<<endl;
   /* for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;*/

}


#include<bits/stdc++.h>
using namespace std;
bool used[1000000];
bool ind[1000000];
int main()
{
    int n,j=0,z=0;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]==0)z++;
        if(ar[i]!=ar[i-1]&&i!=0)
        {
            ans[i]=ar[i-1];
            used[ar[i-1]]=1;
            ind[i]=1;
            used[ar[i]]=1;
        }
    }
    if(z==n)used[0]=1;
    for(int i=0;i<n;i++)
    {
        //cout<<i<<"  "<<ind[i]<<endl;;
        if(!ind[i])
        {
            while(used[j])j++;
            ans[i]=j;
            used[j]=1;
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<< " ";
   cout<<endl;
   /* for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
           // cout<<ar[i]<<"   "<<smallest<<endl;
           if(smallest==0)smallest++;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
          //      cout<<z<<"  "<<ans[j]<< "  "<<smallest<<endl;
                if(ar[i]-smallest>0)
                {
                    if(ans[j]==0&&z==1)continue;
                        else if(ans[j]==0)z--;
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
        if(ans[i]==0)z++;
        //cout<<ar[i]<<"     ";
        //for(int i=0;i<n;i++)cout<<ans[i]<<" ";
        //cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;*/

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
            ////cout<<ar[i]<<"   "<<smallest<<endl;
            smallest++;
            for(int j=i-1;j>0;j--)
            {
                //cout<<j<<"    "<<ar[j]<<endl;
                if(ar[i]-smallest>0&&ans[j]!=0)
                {
                    ans[j]=smallest;
                    smallest++;
                }
                if(smallest==ar[i]) break;
            }
                //ans[i]=smallest;
        }
       // cout<<ar[i]<<"     ";
       // for(int i=0;i<n;i++)cout<<ans[i]<<" ";
       // cout<<endl<<"---------------------------"<<endl;;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,smallest=1;
    cin>>n;
    int ar[n],ans[n];
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            ans[i]=1;
            smallest =0;
        }
        else if(ar[i]==smallest)ans[i]=smallest-1;
        else if (ar[i]-smallest==1)
        {
            ans[i]=smallest;
            smallest++;
        }
        else
        {
            ans[i]=smallest;
            smallest++;
            for(int j=0;j<i;j--)
            {
                if(smallest!=ar[i])ans[j]=smallest;
                else break;
                smallest++;
            }
        }
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];
	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);
		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	// cout<<flag<<endl;
	// for(int i:s) cout<<i<<" ";
	// 	cout<<endl;

	fr(i,2,n+1){

		//cout<<flag<<endl;
		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			last=a[i];
			f[last]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			// cout<<i<<endl;
			// cout<<"i"<<endl;
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];
	fr(i,0,n+1){
		if(vis[i]==0)
			s.insert(i);
	}

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(f[0]){
			cout<<-1;
			return;

		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);
		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
	}
	else if(a[1]==0){
		if(f[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	// cout<<flag<<endl;
	// for(int i:s) cout<<i<<" ";
	// 	cout<<endl;

	fr(i,2,n+1){

		//cout<<flag<<endl;
		int cnt=pref(a[i]-1);
		// if(i==3){
		// 	cout<<cnt<<Endl;
		// 	fr(i,1,n+1) cout<<ans[i]<<" ";
		// 	cout<<endl;
		// }
		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			last=a[i];
			f[last]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			// cout<<i<<endl;
			// cout<<"i"<<endl;
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;
			s.erase(last);

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			if(vis[a[i]]==0 and f[a[i]]==0)
				s.insert(a[i]);

		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			s.erase(*it);
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0 and f[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;
			s.erase(last);

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;

			if(f[*it]==0)
				update(*it,1);

			f[*it]=1;
			s.erase(*it);
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,2*n+5){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			s.erase(*it);
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;
			s.erase(last);

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			s.erase(*it);
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	// cout<<flag<<endl;
	// for(int i:s) cout<<i<<" ";
	// 	cout<<endl;

	fr(i,2,n+1){

		//cout<<flag<<endl;
		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			// cout<<i<<endl;
			// cout<<"i"<<endl;
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		// if(vis[a[1]]==0)
		// 	s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		// if(vis[a[1]]==0)
		// 	s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;
			s.erase(last);

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];

			ans[i]=*it;

			if(f[*it]==0)
				update(*it,1);

			f[*it]=1;
			s.erase(*it);
			vis[a[i]]--;
			// if(vis[a[i]]==0 and f[a[i]]==0)
			// 	s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;
			s.erase(last);

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			s.erase(*it);
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];
	fr(i,0,n+1){
		if(vis[i]==0)
			s.insert(i);
	}

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);
		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	// cout<<flag<<endl;
	// for(int i:s) cout<<i<<" ";
	// 	cout<<endl;

	fr(i,2,n+1){

		//cout<<flag<<endl;
		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			last=a[i];
			f[last]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			// cout<<i<<endl;
			// cout<<"i"<<endl;
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];
	fr(i,0,n+1){
		if(vis[i]==0)
			s.insert(i);
	}

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);
		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	// cout<<flag<<endl;
	// for(int i:s) cout<<i<<" ";
	// 	cout<<endl;

	fr(i,2,n+1){

		//cout<<flag<<endl;
		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			last=a[i];
			f[last]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){

			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			// cout<<i<<endl;
			// cout<<"i"<<endl;
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 13.06.2020
 */

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define fill(x,y) memset(x,y,sizeof(x))
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
#define ll long long
#define ld long double
#define S second
#define F first
#define endl "\n"
#define Endl "\n"
#define all(v) (v).begin(), (v).end()
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string abc="abcdefghijklmnopqrstuvwxyz";
const double PI=acosl(-1);
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e6 + 5;

int n,m;
int a[N];
set<int>s;
int ans[N];
int bit[N];
int ff=0;
void update(int idx, int val)
{
	if(idx==0){
		ff=1;
		return;
	}

    while(idx<=N)
    {
        bit[idx]+=val;
        idx+=idx&-idx;
    }
}

int pref(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=bit[idx];
        idx-=idx&-idx;
    }
    return ans+ff;
}

int rsum(int l, int r)
{
    return pref(r) - pref(l-1);
}

int f[N];

int vis[N];

void solve(){

	cin>>n;
	fr(i,1,n+1) cin>>a[i];

	fr(i,1,n+1) ++vis[a[i]];

	fr(i,0,1e6+1){
		if(vis[i]==0)
			s.insert(i);
	}
	s.insert(n+1);

	int flag=1;
	int last=0;
	if(a[1]==1){
		if(vis[0]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(1);

		ans[1]=0;
		update(0,1);
		f[0]=1;
		last=1;
		s.erase(0);
	}
	else if(a[1]==0){
		if(vis[1]){
			cout<<-1;
			return;
		}
		vis[a[1]]--;
		if(vis[a[1]]==0)
			s.insert(0);

		ans[1]=1;
		update(1,1);
		f[1]=1;
		last=0;
		s.erase(1);
	}
	else
		flag=0;

	if(flag==0){
		cout<<-1;
		return;
	}

	fr(i,2,n+1){

		//cout<<flag<<endl;

		// fr(i,1,n+1) cout<<ans[i]<<" ";
		// cout<<endl;
		// cout<<last<<Endl;

		int cnt=pref(a[i]-1);

		if(cnt+1==a[i]){
			ans[i]=last;

			if(!f[last])
				update(last,1);
			f[last]=1;
			last=a[i];
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);
		}
		else if(cnt==a[i]){
			//cout<<"i"<<endl;
			auto it=s.lower_bound(a[i]);
			if(it==s.end()){
				flag=0;
				break;
			}
			last=a[i];
			ans[i]=*it;
			s.erase(*it);
			if(f[*it]==0)
				update(*it,1);
			f[*it]=1;
			vis[a[i]]--;
			if(vis[a[i]]==0)
				s.insert(a[i]);

		}
		else{
			flag=0;
			break;

		}
	}

	if(flag){
		fr(i,1,n+1) cout<<ans[i]<<" ";
	}
	else{
		cout<<-1;
	}

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	//freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
	//cin>>t;  // UNCOMMENT FOR TEST-CASES
	//precompute();
	while(t--) {
		solve();
	}
	return 0;
}


/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s)
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int n;
	R(n);
	vi a(n);
	vi b(n);
	rv(a);
	map<int,int>hash;
	for(auto x : a)
		hash[x] = 1;
	vi not_used;
	for(i=0;i<=1e6;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	int mex = 1;
	if(a[0] == 0)
	{
		b[0] = 1;
		mex = 0;
	}
	else
	{
		b[0] = 0;
		mex = 1;
	}
	int k = 1;
	for(i=1;i<sz(a);i++)
	{
		if(a[i] == a[i-1])
			b[i] = not_used[k++];
		else
		{
			b[i] = a[i-1];
		}
	}
	wv(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s)
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int n;
	R(n);
	vi a(n);
	vi b(n);
	rv(a);
	map<int,int>hash;
	for(auto x : a)
		hash[x] = 1;
	vi not_used;
	for(i=0;i<=1e6;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	b[0] = not_used[k++];
	for(i=1;i<sz(a);i++)
	{
		if(a[i] == a[i-1])
			b[i] = not_used[k++];
		else
		{
			b[i] = a[i-1];
		}
	}
	wv(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s)
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int n;
	R(n);
	vi a(n);
	vi b(n);
	rv(a);
	map<int,int>hash;
	for(auto x : a)
		hash[x] = 1;
	vi not_used;
	for(i=0;i<=1e6;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	int k = 0;
	b[0] = not_used[k++];
	for(i=1;i<sz(a);i++)
	{
		if(a[i] == a[i-1])
			b[i] = not_used[k++];
		else
		{
			b[i] = a[i-1];
		}
	}
	wv(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s)
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int n;
	R(n);
	vll a(n);
	vll b(n);
	rv(a);
	map<ll,ll>hash;
	for(auto x : a)
		hash[x] = 1;
	vll not_used;
	for(i=0;i<=1e6;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	map<ll,ll>hash1;
	ll mex = 0;
	ll k = 0;
	b[0] = not_used[k++];
	for(i=1;i<sz(a);i++)
	{
		if(a[i] == a[i-1])
		{
			b[i] = not_used[k++];
			hash1[b[i]] = 1;
		/*	while(hash1[mex])
				mex++;
			if(mex != a[i])
			{
				W(-1);
				re;
			}*/
		}
		else
		{
			b[i] = a[i-1];
		/*	hash1[b[i]] = 1;
			while(hash1[mex])
				mex++;
			if(a[i] != mex)
			{
				W(-1);
				re;
			}
			*/
		}
	}
	wv(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s)
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int n;
	R(n);
	vi a(n);
	vi b(n);
	rv(a);
	map<int,int>hash;
	for(auto x : a)
		hash[x] = 1;
	vi not_used;
	for(i=0;i<=n;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	map<int,int>hash1;
	int mex = 0;
	int k = 0;
	b[0] = not_used[k++];
	hash1[b[0]] = 1;
	while(hash1[mex])
	{
		dbg(hash1[mex]);
		mex++;
	}
	if(a[0] != mex)
	{
		W(-1);
		re;
	}
	for(i=1;i<sz(a);i++)
	{
		if(a[i] == a[i-1])
		{
			b[i] = not_used[k++];
			hash1[b[i]] = 1;
			while(hash1[mex])mex++;
			if(a[i] != mex)
			{
				W(-1);
				re;
			}
		}
		else
		{
			b[i] = a[i-1];
			hash1[b[i]] = 1;
			while(hash1[mex])mex++;
			if(a[i] != mex)
			{
				W(-1);
				re;
			}
		}
	}
	wv(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}