#include <bits/stdc++.h>
using namespace std;
const int N=2e5+1;
int a[N],c[N][2];
int b[N];
vector<int> g[N];
bool vis[N];
void dfs(int v,bool fl,int val,int from){
if(fl==0){
for(int j=0;j<g[v].size();++j){
if(!vis[g[v][j]]){
swap(g[v].back(),g[v][j]);
int x=g[v].back();
g[v].pop_back();
dfs(x,1,val^1,v);
break;
}
else{
swap(g[v].back(),g[v][j]);
j--;
g[v].pop_back();
}
}
}
else{
vis[v]=1;
if(a[v]==from){
c[v][val]=from;
c[v][val^1]=b[v];
if(b[v]!=from){
dfs(b[v],0,val^1,v);
}
}
else if(b[v]==from){
swap(a[v],b[v]);
c[v][val]=from;
c[v][val^1]=b[v];
if(b[v]!=from){
dfs(b[v],0,val^1,v);
}
}
else{
c[v][val]=a[v];
c[v][val^1]=b[v];
if(b[v]!=a[v]){
dfs(b[v],0,1,v);
dfs(a[v],0,0,v);
}
else{
dfs(b[v],0,0,v);
}
}
}
}
void upsolve(){
int n;
cin>>n;
for(int i=1;i<=n;++i){
cin>>a[i];
}
set<int> st;
for(int i=1;i<2*n;++i){
st.insert(i);
}
cout<<a[1]<<' ';
st.erase(a[1]);
for(int i=2;i<=n;++i){
if(a[i]<a[i-1]){
cout<<*st.begin()<<' ';
st.erase(st.begin());
if(st.find(a[i])==st.end()){
cout<<*st.begin()<<' ';
st.erase(st.begin());
}
else{
cout<<a[i]<<' ';
st.erase(a[i]);
}
st.erase(a[i]);
}
else if(a[i]>a[i-1]){
cout<<*st.rbegin()<<' ';
st.erase(*st.rbegin());
if(st.find(a[i])==st.end()){
cout<<*st.rbegin()<<' ';
st.erase(*st.rbegin());
}
else{
cout<<a[i]<<' ';
st.erase(a[i]);
}
}
else{
cout<<*st.begin()<<" "<<*st.rbegin()<<' ';
st.erase(st.begin());
st.erase(*st.rbegin());
}
}
}
int main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
int t;
t=1;
while(t--){
upsolve();
}
return 0;
}