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

#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);
	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;
	if(a[0] == 0)
	{
		b[0] = 1;
		hash1[1] = 1;
		mex = 0;
	}
	else
	{
		b[0] = 0;
		hash1[0] = 1;
		mex = 1;
	}
	ll k = 0;
	if(not_used[0] == 0 || not_used[0] == 1)
		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<=1e6;i++)
		if(hash[i] == 0)
			not_used.pb(i);
	map<int,int>hash1;
	int mex = 0;
	if(a[0] == 0)
	{
		b[0] = 1;
		hash1[1] = 1;
		mex = 0;
	}
	else
	{
		b[0] = 0;
		hash1[0] = 1;
		mex = 1;
	}
	int k = 1;
	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;

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    map<int,int> p;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[a[i]]++;
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    queue<int> bl;
    int q = 0;
    for(int i = 0; i < n; i++){
        if(s.size()){
            if(a[s.front()]==a[i] and i!=0){
            p[a[i-1]] = 0;
            if(bl.size()){
                b[i] = bl.front();
                bl.pop();
                s.pop();
                continue;
            }
            s.pop();
        }
        }
        if(i==0){
            s.pop();
        }
        if(p[bt]>0){
            while(p[bt]>0){
                bl.push(bt);
                bt++;
            }
            b[i] = bt;
            bt++;
        }
        else{
            b[i] = bt++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
    }
    for(int i = 0; i < n; i++){
        if(a[i] == bt){
            b[i] = ++gabe;
        }
        else{
            b[i] = bt;
            bt++;
        }
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    map<int,int> p;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[a[i]]++;
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    s.push(2*n);
    s.push(4*n);
    queue<int> bl;
    int q = 0;
    for(int i = 0; i < n; i++){
        if(a[s.front()]==a[i] and i!=0){
            b[i] = bl.front();
            bl.pop();
            s.pop();
            //cout << a[i] << "\n";
            continue;

        }
        if(i==0){
            s.pop();
        }
        if(p[bt]>0){
            while(p[bt]>0){
                bl.push(bt);
                bt++;
            }
            b[i] = bt;
            bt++;
        }
        else{
            b[i] = bt++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    int fgabe = gabe;
    queue<int> bl;
    for(int i = 0; i < n; i++){
        bool popped = false;
        if(fgabe < bt and bt <= gabe){
            bt = ++gabe;
        }
        if(s.size()>0){
            if(a[i] == a[s.front()]){
            s.pop();
            if(bl.size()>0){
                b[i] = bl.front();
                bl.pop();
                popped = true;
            }
        }
        }
        if(a[i] == bt){
            bl.push(bt);
            bt++;
        }
        if(!popped){
            if(bt == a[s.front()]){
                b[i] = ++gabe;
            }
            else{
                b[i] = bt++;
            }
        }
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
    }
    int fgabe = gabe;
    for(int i = 0; i < n; i++){
        if(fgabe < bt and bt < gabe){
            bt = gabe;
        }
        if(a[i] == bt){
            b[i] = ++gabe;
        }
        else{
            b[i] = a[i]-1;
            bt = b[i];
        }
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    int fgabe = gabe;
    queue<int> bl;
    for(int i = 0; i < n; i++){
        bool popped = false;
        if(fgabe < bt and bt <= gabe){
            bt = ++gabe;
        }
        if(a[i] == a[s.front()]){
            s.pop();
            if(bl.size()){
                b[i] = bl.front();
                bl.pop();
                popped = true;
            }
        }
        if(a[i] == bt){
            bl.push(bt);
            bt++;
        }
        if(!popped){
            if(bt == a[s.front()]){
                b[i] = ++gabe;
            }
            else{
                b[i] = bt++;
            }
        }
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    map<int,int> p;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[a[i]]++;
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    s.push(2*n);
    s.push(4*n);
    queue<int> bl;
    int q = 0;
    for(int i = 0; i < n; i++){
        if(a[s.front()]==a[i] and i!=0){
            p[a[i-1]] = 0;
            if(bl.size()){
                b[i] = bl.front();
                bl.pop();
                s.pop();
                continue;
            }
            s.pop();
        }
        if(i==0){
            s.pop();
        }
        if(p[bt]>0){
            while(p[bt]>0){
                bl.push(bt);
                bt++;
            }
            b[i] = bt;
            bt++;
        }
        else{
            b[i] = bt++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    int fgabe = gabe;
    queue<int> bl;
    for(int i = 0; i < n; i++){
        bool popped = false;
        if(fgabe < bt and bt <= gabe){
            bt = ++gabe;
        }
        if(a[i] == a[s.front()]){
            s.pop();
            if(bl.size()>0){
                b[i] = bl.front();
                bl.pop();
                popped = true;
            }
        }
        if(a[i] == bt){
            bl.push(bt);
            bt++;
        }
        if(!popped){
            if(bt == a[s.front()]){
                b[i] = ++gabe;
            }
            else{
                b[i] = bt++;
            }
        }
        cout << b[i] << " ";
    }
    cout << "\n";
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int bt = 0;
    int gabe = 0;
    queue<int> s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        gabe = max(gabe,a[i]);
        if(i==0){
            s.push(i);
        }
        else if(a[i]>a[i-1]){
            s.push(i);
        }
    }
    int fgabe = gabe;
    queue<int> bl;
    for(int i = 0; i < n; i++){
        bool popped = false;
        if(fgabe < bt and bt <= gabe){
            bt = ++gabe;
        }
        if(a[i] == a[s.front()]){
            s.pop();
            if(bl.size()){
                b[i] = bl.front();
                bl.pop();
                popped = true;
            }
        }
        if(a[i] == bt){
            bl.push(bt);
            bt++;
        }
        if(!popped){
            if(bt == a[s.front()]){
                b[i] = ++gabe;
            }
            else{
                b[i] = bt++;
            }
        }
        cout << b[i] << " ";
    }
    cout << "\n"; //tite
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        i--;
        if(i < 0) break;
        // cout<<i<<" ";
        // cout<<j<<" ";
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    see(b);
    int k = 0;
    int j = n-1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    if(mx == 0) mx = 1;
    map<int,int> taken;
    for(int i=0;i<=a[n-1]+1;i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<mx;i++) {
        if(!taken[i] && k < j) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    if(a[n-1] == 0) {
        for(int i=0;i<n;i++) cout<<1<<" ";
        return 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    taken[a[0]] = 1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) taken[b[i]] = 1;
    }
    taken[a[n-1]] = 1;
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    //see(t);
    k = 0;
    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    if(a[n-1] == 0) {
        for(int i=0;i<n;i++) cout<<1<<" ";
        return 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=n;i++) taken[i] = 0;
    taken[a[0]] = 1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) taken[b[i]] = 1;
    }
    taken[a[n-1]] = 1;
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    //see(t);
    k = 0;

    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    if(a[n-1] == 0) {
        for(int i=0;i<n;i++) cout<<1<<" ";
        return 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    taken[a[0]] = 1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) taken[b[i]] = 1;
    }
    taken[a[n-1]] = 1;
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    //see(t);
    k = 0;
    if(t.size() == 0) return cout<<-1, 0;
    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i-1>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        if(i-1 < 0) break;
        i--;
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    int k = 0;
    int j;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<=a[n-1];i++) {
        if(!taken[i]) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i-1>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        if(i-1 < 0) break;
        i--;
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    int k = 0;
    int j;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<=a[n-1];i++) {
        if(!taken[i]) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i-1>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        i--;
        if(i < 0) break;
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    int k = 0;
    int j = n-1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    if(mx == 0) mx = 1;
    map<int,int> taken;
    for(int i=0;i<=a[n-1]+1;i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<=a[n-1];i++) {
        if(!taken[i]) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        i--;
        if(i < 0) break;
        cout<<i<<" ";
        cout<<j<<" ";
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    see(b);
    int k = 0;
    int j = n-1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    if(mx == 0) mx = 1;
    map<int,int> taken;
    for(int i=0;i<=a[n-1]+1;i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<mx;i++) {
        if(!taken[i] && k < j) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[n-1] == 0) {
        for(int i=0;i<n;i++) cout<<1<<" ";
        return 0;
    }
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) {
        taken[a[i]] = 1;
    }
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    see(t);
    k = 0;
    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) {
        taken[a[i]] = 1;
    }
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    see(t);
    k = 0;
    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    if(a[n-1] == 0) {
        for(int i=0;i<n;i++) cout<<1<<" ";
        return 0;
    }
    vi b(n, -1);
    int k = a[0];
    for(int i=0;i<n-1;i++) {
        if(a[i] != a[i+1]) b[i+1] = k;
        k = a[i+1];
    }
    //see(b);
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) {
        taken[a[i]] = 1;
    }
    vi t;
    for(auto i : taken) {
        if(!i.second) t.pb(i.first);
    }
    sort(all(t));
    //see(t);
    k = 0;
    for(int i=0;i<n;i++) {
        if(b[i] == -1) {
            b[i] = t[k], k++;
            if(k > t.size()-1) k = t.size()-1;
        }
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = t[0];
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define fast ios_base :: sync_with_stdio(0);cin.tie(0);
#define int long long
using namespace std;

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

int32_t main() {
    fast;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(a[0] != 0 && a[0] != 1) return cout<<-1, 0;
    for(int i=0;i<n-1;i++) {
        if(a[i+1] < a[i]) return cout<<-1, 0;
    }
    for(int i=0;i<n;i++) {
        if(a[i] > (i+1)) return cout<<-1, 0;
    }
    vi b(n, -1);
    for(int i=n-1;i-1>=0;) {
        int j = i;
        while(i-1 >= 0 && a[i] == a[i-1]) i--;
        i--;
        if(i < 0) break;
        for(int k=i+1;k<=j;k++) b[k] = a[i];
    }
    int k = 0;
    int j = n-1;
    for(int i=0;i<n;i++) {
        if(b[i] != -1) {
            j = i;
            break;
        }
    }
    int mx = a[j];
    if(mx == 0) mx = 1;
    map<int,int> taken;
    for(int i=0;i<=a[n-1];i++) taken[i] = 0;
    for(int i=0;i<n;i++) taken[a[i]] = 1;
    int m = n;
    for(int i=0;i<=a[n-1];i++) {
        if(!taken[i]) m = min(m,i), b[k] = i, k++;
    }
    for(int i=0;i<n;i++) {
        if(b[i] == -1) b[i] = m;
    }
    see(b);
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    int a[n];
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }

    int ans[n];
    set<int> s;
    for(int i = 0 ; i <= n + n ; i++){
    	s.insert(i);
    }

    set<int> numbers;
    for(int i = 0 ; i < n ; i++)ans[i] = -1;
    for(int i = 1 ; i < n ; i++){
    	if(a[i] != a[i-1]){
    		ans[i] = a[i-1];
    		s.erase(a[i-1]);
    		numbers.insert(a[i]);
    	}
    }

    for(int i = 0 ; i < n ; i++){
    	if(ans[i] == -1){
    		if(*(s.begin()) == *(numbers.begin()))s.erase(s.begin());
    		ans[i] = *(s.begin());
    		s.erase(s.begin());
    	}
    	else{
    		numbers.erase(numbers.begin());
    	}
    }

    for(int i = 0 ; i < n ; i++){
    	cout << ans[i] << " ";
    }
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }
    // for(int i = 0 ; i < n ; i++){
    	// if(i + 1 < a[i]){
    		// debug(i);
    		// cout << -1 << endl;
    		// return 0;
    	// }
    // }

  	vector<int> vec = a;
  	int num = unique(all(vec)) - vec.begin();

  	vec.resize(num);

  	// for(int i : vec){
  		// cout << i << endl;
//
  	// }
//

		if(num == 1){
			int cnt = 0;
			for(int i = 0 ; i < n ; i++){
				if(cnt == vec[0])cnt++;
				cout << cnt << " ";
				cnt++;
			}
			return 0;
		}
  	int ans[n];
  	// if(a[0] == 0){
	  	// int cnt = 1 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }
  	// else{
  		// int cnt = 0 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// if(cnt == a[start])cnt = min(cnt + 1 , vec[number + 1] - 1);
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }

  	// cerr << "hello\n";

  	int start = 0;
  	int cnt = 0;
  	while(a[start] != vec[1]){
  			if(cnt == vec[0])cnt = min(cnt + 1 , vec[1] - 1);
  			if(cnt == vec[0])cnt = n + 1;
  			ans[start] = cnt;
  			debug(cnt);
  			cnt = min(cnt + 1 , vec[1] - 1);
  			start++;
  	}
  	for(int i = 1 ; i < num ; i++){
  		ans[start] = vec[i-1];
  		start++;
  		debug(start);
  		while(start < n && a[start] == vec[i]){
  			if(i + 1 == num){
  				ans[start] = ans[start - 1];
  				start++;
  				continue;
  			}
  			cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = cnt - 1;
  			ans[start] = cnt;
  			start++;
  		}
  	}

  	for(int i = 0 ; i < n ; i++){
  		cout << ans[i] << " ";
  	}
  	cout << "\n";
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }
    // for(int i = 0 ; i < n ; i++){
    	// if(i + 1 < a[i]){
    		// debug(i);
    		// cout << -1 << endl;
    		// return 0;
    	// }
    // }

  	vector<int> vec = a;
  	int num = unique(all(vec)) - vec.begin();

  	vec.resize(num);

  	// for(int i : vec){
  		// cout << i << endl;
//
  	// }
//

		if(num == 1){
			for(int i = 0 ; i < n ; i++){
				cout << n+1 << " ";
			}
			return 0;
		}
  	int ans[n];
  	if(a[0] == 0){
	  	int cnt = 1 , number = 0;
	  	for(int i = 0 ; i < n ; ){
	  		int start = i;
	  		while(i < n && vec[number] == a[i]){
	  			i++;
	  		}

	  		// debug(start);
	  		// debug(i);
	  		if(i == n){
	  			for(int j = start ; j < n ; j++){
	  				ans[j] = vec[number - 1];
	  			}
	  		}
	  		else{
	  			if(start)
	  				ans[start] = vec[number - 1] , start++;
		  			for(int j = start ; j < i ; j++){
		  				ans[j] = cnt;
		  				cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			}

	  		}

	  		number++;

	  	}
  	}
  	else{
  		int cnt = 0 , number = 0;
	  	for(int i = 0 ; i < n ; ){
	  		int start = i;
	  		while(i < n && vec[number] == a[i]){
	  			i++;
	  		}

	  		// debug(start);
	  		// debug(i);
	  		if(i == n){
	  			for(int j = start ; j < n ; j++){
	  				ans[j] = vec[number - 1];
	  			}
	  		}
	  		else{
	  			if(start)
	  				ans[start] = vec[number - 1] , start++;
		  			for(int j = start ; j < i ; j++){
		  				if(cnt == a[start])cnt = min(cnt + 1 , vec[number + 1] - 1);
		  				ans[j] = cnt;
		  				cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			}

	  		}

	  		number++;

	  	}
  	}

  	for(int i = 0 ; i < n ; i++){
  		cout << ans[i] << " ";
  	}
  	cout << "\n";
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    int a[n];
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }

    int ans[n];
    set<int> s;
    for(int i = 0 ; i <= n ; i++){
    	s.insert(i);
    }

    set<int> numbers;
    for(int i = 0 ; i < n ; i++)ans[i] = -1;
    for(int i = 1 ; i < n ; i++){
    	if(a[i] != a[i-1]){
    		ans[i] = a[i-1];
    		s.erase(a[i-1]);
    		numbers.insert(a[i]);
    	}
    }

    for(int i = 0 ; i < n ; i++){
    	if(ans[i] == -1){
    		if(*(s.begin()) == *(numbers.begin()))s.erase(s.begin());
    		ans[i] = *(s.begin());
    		s.erase(s.begin());
    	}
    	else{
    		numbers.erase(numbers.begin());
    	}
    }

    for(int i = 0 ; i < n ; i++){
    	cout << ans[i] << " ";
    }
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }
    // for(int i = 0 ; i < n ; i++){
    	// if(i + 1 < a[i]){
    		// debug(i);
    		// cout << -1 << endl;
    		// return 0;
    	// }
    // }

  	vector<int> vec = a;
  	int num = unique(all(vec)) - vec.begin();

  	vec.resize(num);

  	// for(int i : vec){
  		// cout << i << endl;
//
  	// }
//

		if(num == 1){
			int cnt = 0;
			for(int i = 0 ; i < n ; i++){
				if(cnt == vec[0])cnt++;
				cout << cnt << " ";
			}
			return 0;
		}
  	int ans[n];
  	// if(a[0] == 0){
	  	// int cnt = 1 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }
  	// else{
  		// int cnt = 0 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// if(cnt == a[start])cnt = min(cnt + 1 , vec[number + 1] - 1);
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }

  	// cerr << "hello\n";

  	int start = 0;
  	int cnt = 0;
  	while(a[start] != vec[1]){
  			if(cnt == vec[0])cnt = min(cnt + 1 , vec[1] - 1);
  			if(cnt == vec[0])cnt = n + 1;
  			ans[start] = cnt;
  			debug(cnt);
  			cnt = min(cnt + 1 , vec[1] - 1);
  			start++;
  	}
  	for(int i = 1 ; i < num ; i++){
  		ans[start] = vec[i-1];
  		start++;
  		debug(start);
  		while(start < n && a[start] == vec[i]){
  			if(i + 1 == num){
  				ans[start] = ans[start - 1];
  				start++;
  				continue;
  			}
  			cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = ans[start - 1];
  			ans[start] = cnt;
  			start++;
  		}
  	}

  	for(int i = 0 ; i < n ; i++){
  		cout << ans[i] << " ";
  	}
  	cout << "\n";
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }
    // for(int i = 0 ; i < n ; i++){
    	// if(i + 1 < a[i]){
    		// debug(i);
    		// cout << -1 << endl;
    		// return 0;
    	// }
    // }

  	vector<int> vec = a;
  	int num = unique(all(vec)) - vec.begin();

  	vec.resize(num);

  	// for(int i : vec){
  		// cout << i << endl;
//
  	// }
//

		if(num == 1){
			int cnt = 0;
			for(int i = 0 ; i < n ; i++){
				if(cnt == vec[0])cnt++;
				cout << cnt << " ";
			}
			return 0;
		}
  	int ans[n];
  	if(a[0] == 0){
	  	int cnt = 1 , number = 0;
	  	for(int i = 0 ; i < n ; ){
	  		int start = i;
	  		while(i < n && vec[number] == a[i]){
	  			i++;
	  		}

	  		// debug(start);
	  		// debug(i);
	  		if(i == n){
	  			for(int j = start ; j < n ; j++){
	  				ans[j] = vec[number - 1];
	  			}
	  		}
	  		else{
	  			if(start)
	  				ans[start] = vec[number - 1] , start++;
		  			for(int j = start ; j < i ; j++){
		  				ans[j] = cnt;
		  				cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			}

	  		}

	  		number++;

	  	}
  	}
  	else{
  		int cnt = 0 , number = 0;
	  	for(int i = 0 ; i < n ; ){
	  		int start = i;
	  		while(i < n && vec[number] == a[i]){
	  			i++;
	  		}

	  		// debug(start);
	  		// debug(i);
	  		if(i == n){
	  			for(int j = start ; j < n ; j++){
	  				ans[j] = vec[number - 1];
	  			}
	  		}
	  		else{
	  			if(start)
	  				ans[start] = vec[number - 1] , start++;
		  			for(int j = start ; j < i ; j++){
		  				if(cnt == a[start])cnt = min(cnt + 1 , vec[number + 1] - 1);
		  				ans[j] = cnt;
		  				cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			}

	  		}

	  		number++;

	  	}
  	}

  	for(int i = 0 ; i < n ; i++){
  		cout << ans[i] << " ";
  	}
  	cout << "\n";
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    int a[n];

    set<int> s;
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    	s.insert(a[i]);
    }

    int ans[n];
    int cnt = 0;
    for(int i = 0 ; i < n ; i++){
    	if(i > 0 && a[i] != a[i-1]){
    		ans[i] = a[i-1];
    	}
    	else{
    		while(s.count(cnt))cnt++;
    		ans[i] = cnt;
    		cnt++;
    	}
    }

    for(int i = 0 ; i < n ; i++){
    	cout << ans[i] << " ";
    }
    return 0;
}


// Problem : C. Ehab and Prefix MEXs
// Contest : Codeforces - Codeforces Round #649 (Div. 2)
// URL : https://codeforces.com/contest/1364/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    }
    // for(int i = 0 ; i < n ; i++){
    	// if(i + 1 < a[i]){
    		// debug(i);
    		// cout << -1 << endl;
    		// return 0;
    	// }
    // }

  	vector<int> vec = a;
  	int num = unique(all(vec)) - vec.begin();

  	vec.resize(num);

  	// for(int i : vec){
  		// cout << i << endl;
//
  	// }
//

		if(num == 1){
			int cnt = 0;
			for(int i = 0 ; i < n ; i++){
				if(cnt == vec[0])cnt++;
				cout << cnt << " ";
			}
			return 0;
		}
  	int ans[n];
  	// if(a[0] == 0){
	  	// int cnt = 1 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }
  	// else{
  		// int cnt = 0 , number = 0;
	  	// for(int i = 0 ; i < n ; ){
	  		// int start = i;
	  		// while(i < n && vec[number] == a[i]){
	  			// i++;
	  		// }
//
	  		// // debug(start);
	  		// // debug(i);
	  		// if(i == n){
	  			// for(int j = start ; j < n ; j++){
	  				// ans[j] = vec[number - 1];
	  			// }
	  		// }
	  		// else{
	  			// if(start)
	  				// ans[start] = vec[number - 1] , start++;
		  			// for(int j = start ; j < i ; j++){
		  				// if(cnt == a[start])cnt = min(cnt + 1 , vec[number + 1] - 1);
		  				// ans[j] = cnt;
		  				// cnt = min(cnt + 1 , vec[number + 1] - 1);
		  			// }
//
	  		// }
//
	  		// number++;
//
//
	  	// }
  	// }

  	// cerr << "hello\n";

  	int start = 0;
  	int cnt = 0;
  	while(a[start] != vec[1]){
  			if(cnt == vec[0])cnt = min(cnt + 1 , vec[1] - 1);
  			if(cnt == vec[0])cnt = n + 1;
  			ans[start] = cnt;
  			debug(cnt);
  			cnt = min(cnt + 1 , vec[1] - 1);
  			start++;
  	}
  	for(int i = 1 ; i < num ; i++){
  		ans[start] = vec[i-1];
  		start++;
  		debug(start);
  		while(start < n && a[start] == vec[i]){
  			if(i + 1 == num){
  				ans[start] = ans[start - 1];
  				start++;
  				continue;
  			}
  			cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = min(cnt + 1 , vec[i+1] - 1);
  			if(cnt == vec[i])cnt = cnt - 1;
  			ans[start] = cnt;
  			start++;
  		}
  	}

  	for(int i = 0 ; i < n ; i++){
  		cout << ans[i] << " ";
  	}
  	cout << "\n";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[a[i]] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        while(cur <= n && frst[cur] > i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[a[i]] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(cur <= n && frst[cur] != i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[a[i]] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(cur <= n && frst[cur] != -1)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[i] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(frst[cur] > i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] > i + 1){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(frst[cur] > i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[a[i]] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(cur <= n && frst[cur] > i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(frst[cur] > i)++cur;
        b[i] = cur;
        ++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(frst[a[i]] >= 0 && frst[a[i]] != i){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(frst[cur] > i)++cur;
        b[i] = cur;
        if(cur < n)++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


#include <bits/stdc++.h>
//#define int long long
#define pb emplace_back
#define mp make_pair
#define x first
#define y second

typedef long double ld;
typedef long long ll;

using namespace std;

mt19937 rnd(143);

const int inf = 1e9;
const int M = 1e9 + 7;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> frst(n + 1, -1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] > i + 1){
            cout << -1;
            return 0;
        }
        frst[a[i]] = i + 1;
    }
    vector<int> b(n, -1);
    for(int i = 0; i < n; ++i){
        if(frst[i] < n)b[frst[i]] = i;
        /*if(frst[i] < i){
            cout << -1;
            return 0;
        }*/
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] >= 0)continue;
        while(frst[cur] > i)++cur;
        b[i] = cur;
        ++cur;
    }
    for(int e: b)cout << e << " ";
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int valid[110005];
int ans[100005];

// CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
    }
    int mn, val = 2, prev;
    if(arr[0]==0) {
        ans[0] = 1;
        mn = 0;
    }
    else if(arr[0]==1) {
        ans[0] = 0;
        mn = 1;
    }
    else cout<<"-1"<<endl;

    int flag = 1;
    prev = arr[0];
    for(int i=1; i<n; ++i) {
        if(arr[i]!=prev) {
            ans[i] = mn;
            mn = arr[i];
        }
        else {
            while(valid[val]!=0) {
                ++val;
            }
            ans[i] = val;
            valid[val] = 1;
        }
        prev = arr[i];
    }

    for(int i=0; i<n; ++i) {
        if(i>0) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int valid[110005];
int ans[100005];

// CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
    }

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mn, val = 0, prev;
        int flag = 1;
        prev = arr[0];
        for(int i=0; i<n; ++i) {
            if(i==0) mn = arr[i];
            if(arr[i]!=prev) {
                ans[i] = mn;
                mn = arr[i];
            }
            else {
                while(valid[val]!=0) {
                    ++val;
                }
                ans[i] = val;
                valid[val] = 1;
            }
            prev = arr[i];
        }

        for(int i=0; i<n; ++i) {
            if(i>0) cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005], valid[120005];
vector < pair <int, int> > v;
vector <int> v2;

int update(int first, int last, int val, int num, int mx) {
    for(int i=first; i<=last; ++i) {
        while(valid[val]!=0) {
            ++val;
        }
        ans[i] = val;
        valid[val] = 1;
    }
    return val+1;
}

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
        if(i==0) {
            num = arr[i];
            first = 0;
        }
        if(i>0) {
            if(arr[i]!=prev) {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size();
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int flag = 1, val = 2;
            for(int i=0; i<sz-1; ++i) {
                if(i>0) {
                    ans[v[i].first] = mn;
                    mn = v2[i];
                    val = flag;
                }
                flag = update(v[i].first+1, v[i].second, val, v2[i+1], mx);
                if(flag==-1) break;
            }
            if((v2[0]==0 && v2[1]==1) || (v2[0]==1 && v2[1]==0)) flag = -1;
            if(flag==-1) cout<<"-1"<<endl;
            else {
                ans[v[sz-1].first] = mn;
                for(int i=v[sz-1].first+1; i<=v[sz-1].second; ++i) {
                    ans[i] = mx;
                }

                for(int i=0; i<n; ++i) {
                    if(i>0) cout<<" ";
                    cout<<ans[i];
                }
                cout<<endl;
            }
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005];
vector < pair <int, int> > v;
vector <int> v2;

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        if(i==0) num = arr[i];
        if(i>0) {
            if(arr[i]==prev) first = 0;
            else {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size();
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int val = 2, endFlag = 1;
            for(int i=0; i<sz; ++i) {
                if(i>0 && val!=v2[i]) {
                    endFlag = 0;
                    break;
                }
                else if(i>0) ++val;
                int pos = v[i].first;
                if(i>0) {
                    ans[pos] = mn;
                    ++pos;
                    mn = v2[i];
                }
                if(i==0) ++pos;
                for(int j=pos; j<=v[i].second; ++j) {
                    if(i+1<sz && val==v2[i+1]) ans[j] = mx;
                    else {
                        ans[j] = val;
                        ++val;
                    }
                }
            }

            for(int i=0; i<n; ++i) {
                if(i>0) cout<<" ";
                cout<<ans[i];
            }
            cout<<endl;
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005];
vector < pair <int, int> > v;
vector <int> v2;

int update(int first, int last, int val, int num, int mx) {
    for(int i=first; i<=last; ++i) {
        if(val==num) ans[i] = mx;
        else {
            ans[i] = val;
            ++val;
        }
    }
    if(val<=num-1) return -1;
    return 1;
}

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        if(i==0) {
            num = arr[i];
            first = 0;
        }
        if(i>0) {
            if(arr[i]!=prev) {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size();
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int flag = 1, val = 2;
            for(int i=0; i<sz-1; ++i) {
                if(i>0) {
                    ans[v[i].first] = mn;
                    mn = v2[i];
                    val = v2[i]+1;
                }
                flag = update(v[i].first+1, v[i].second, val, v2[i+1], mx);
                if(flag==-1) break;
            }
            if((v2[0]==0 && v2[1]==1) || (v2[0]==1 && v2[1]==0)) flag = -1;
            if(flag==-1) cout<<"-1"<<endl;
            else {
                ans[v[sz-1].first] = mn;
                for(int i=v[sz-1].first+1; i<=v[sz-1].second; ++i) {
                    ans[i] = mx;
                }

                for(int i=0; i<n; ++i) {
                    if(i>0) cout<<" ";
                    cout<<ans[i];
                }
                cout<<endl;
            }
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005], valid[120005];
vector < pair <int, int> > v;
vector <int> v2;

int update(int first, int last, int val, int num, int mx) {
    for(int i=first; i<=last; ++i) {
        while(valid[val]!=0) {
            ++val;
        }
        ans[i] = val;
        valid[val] = 1;
    }
    if(val+1<num) return -1;
    return val+1;
}

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
        if(i==0) {
            num = arr[i];
            first = 0;
        }
        if(i>0) {
            if(arr[i]!=prev) {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size(), flag = 1;
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int val = 2;
            for(int i=0; i<sz-1; ++i) {
                if(i>0) {
                    ans[v[i].first] = mn;
                    mn = v2[i];
                    val = flag;
                }
                flag = update(v[i].first+1, v[i].second, val, v2[i+1], mx);
                if(flag==-1) break;
            }
            if((v2[0]==0 && v2[1]==1) || (v2[0]==1 && v2[1]==0)) flag = -1;
            if(flag==-1) cout<<"-1"<<endl;
            else {
                ans[v[sz-1].first] = mn;
                for(int i=v[sz-1].first+1; i<=v[sz-1].second; ++i) {
                    ans[i] = mx;
                }
            }
        }
        if(flag!=-1) {
            for(int i=0; i<n; ++i) {
                if(i>0) cout<<" ";
                cout<<ans[i];
            }
            cout<<endl;
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005], valid[120005];
vector < pair <int, int> > v;
vector <int> v2;

int update(int first, int last, int val, int num, int mx) {
    int prev = val;
    for(int i=first; i<=last; ++i) {
        while(valid[val]!=0) {
            ++val;
        }
        ans[i] = val;
        cout<<val<<endl;
        valid[val] = 1;
    }
    if(val==prev) return val;
    if(val+1<num) return -1;
    return val+1;
}

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
        if(i==0) {
            num = arr[i];
            first = 0;
        }
        if(i>0) {
            if(arr[i]!=prev) {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size(), flag = 1;
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int val = 2;
            for(int i=0; i<sz-1; ++i) {
                if(i>0) {
                    ans[v[i].first] = mn;
                    mn = v2[i];
                    val = flag;
                }
                flag = update(v[i].first+1, v[i].second, val, v2[i+1], mx);
                if(flag==-1) break;
            }
            if((v2[0]==0 && v2[1]==1) || (v2[0]==1 && v2[1]==0)) flag = -1;
            if(flag==-1) cout<<"-1"<<endl;
            else {
                ans[v[sz-1].first] = mn;
                for(int i=v[sz-1].first+1; i<=v[sz-1].second; ++i) {
                    ans[i] = mx;
                }
            }
        }
        if(flag!=-1) {
            for(int i=0; i<n; ++i) {
                if(i>0) cout<<" ";
                if(ans[i]<10) cout<<"0";
                cout<<ans[i];
            }
            cout<<endl;
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

int arr[100005];
int ans[100005], valid[120005];
vector < pair <int, int> > v;
vector <int> v2;

int update(int first, int last, int val, int num, int mx) {
    for(int i=first; i<=last; ++i) {
        while(valid[val]!=0) {
            ++val;
        }
        ans[i] = val;
        valid[val] = 1;
    }
    if(val+1<num) return -1;
    return val+1;
}

//CHECK LONG LONG

int main() {
    ios_base::sync_with_stdio(false);

    int n, num, prev, first;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>arr[i];
        valid[arr[i]] = 1;
        if(i==0) {
            num = arr[i];
            first = 0;
        }
        if(i>0) {
            if(arr[i]!=prev) {
                v2.push_back(num);
                v.push_back(make_pair(first, i-1));
                first = i;
                num = arr[i];
            }
        }
        prev = arr[i];
    }
    v2.push_back(num);
    v.push_back(make_pair(first, n-1));

    if(arr[0]>1) cout<<"-1"<<endl;
    else {
        int mx = 1000000, mn;
        if(arr[0]==1) {
            ans[0] = 0;
            mn = 1;
        }
        else {
            ans[0] = 1;
            mn = 0;
        }
        int sz = v2.size();
        if(sz==1) {
            int val = 2;
            for(int i=1; i<n; ++i) {
                ans[i] = val;
            }
        }
        else {
            int flag = 1, val = 2;
            for(int i=0; i<sz-1; ++i) {
                if(i>0) {
                    ans[v[i].first] = mn;
                    mn = v2[i];
                    val = flag;
                }
                flag = update(v[i].first+1, v[i].second, val, v2[i+1], mx);
                if(flag==-1) break;
            }
            if((v2[0]==0 && v2[1]==1) || (v2[0]==1 && v2[1]==0)) flag = -1;
            if(flag==-1) cout<<"-1"<<endl;
            else {
                ans[v[sz-1].first] = mn;
                for(int i=v[sz-1].first+1; i<=v[sz-1].second; ++i) {
                    ans[i] = mx;
                }

                for(int i=0; i<n; ++i) {
                    if(i>0) cout<<" ";
                    cout<<ans[i];
                }
                cout<<endl;
            }
        }
    }
    return 0;
}