#Input = raw_input()
n, m = list(map(int, raw_input().split()))

#line = raw_input()
a = list(map(int, raw_input().split()))

#line = raw_input()
b = list(map(int, raw_input().split()))

#n = Inputs[0]
#m = Inputs[1]

i = 0
j = 0
result = sum(1 for item in a if item <= 10**6)
count = 0

for i in range(n):
    if a[i] <= 10**6:
        for j in range(m):
            if a[i] > b[j]:
                j += 1
            elif a[i] == b[j]:
                count += 1
                j += 1
                break
            else:
                break
    else:
        break

result -= count

print result


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number=1;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        while(temp.empty())
        {
            temp.pop();
        }
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        int flag=1;
        while(temp.empty()==1)
        {
            for(int i=n; i>=1; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                }
            }
        }
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==0&&flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        number=1;
        while(temp.empty()==1)
        {
            temp.pop();
        }
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        if(temp.empty()==1)
        {
            for(int i=n; i>=1; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                }
            }
        }
        int flag=1;
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==1&&flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        number=1;
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        int flag=1;
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==1)
            {
                break;
            }
            if(flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=n;i>=flag; i--)
        {
            if(vis[i]==0)
            {
                ans.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        number=1;
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        if(temp.empty()==1)
        {
            for(int i=n; i>=1; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                }
            }
        }
        int flag=1;
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==1&&flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number=1;
stack<int>temp;
vector<int>ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
        vis[a[i]]=1;
        temp.push(a[i]);
        while(temp.empty()==0&&temp.top()==number)
        {
            temp.pop();
            number++;
        }
    }
    int flag=1;
    while(temp.empty()==1)
    {
        for(int i=n;i>=1;i--)
        {
            if(vis[i]==0)
            {
                ans.push_back(i);
            }
        }
    }
    while(temp.empty()==0)
    {
        for(int i=temp.top();i>=flag;i--)
        {
            if(vis[i]==0)
            {
                ans.push_back(i);
                vis[i]=1;
            }
        }
        flag=temp.top();
        temp.pop();
        if(temp.empty()==0&&flag>temp.top())
        {
            printf("-1\n");
            return 0;
        }
    }
    for(int i=1;i<=m;i++)
    {
        if(i==1)
        {
            printf("%d",a[i]);
        }
        else
        {
            printf(" %d",a[i]);
        }
    }
    for(int i=0;i<ans.size();i++)
    {
        printf(" %d",ans[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number=1;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        temp.clear();
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        int flag=1;
        while(temp.empty()==1)
        {
            for(int i=n; i>=1; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                }
            }
        }
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==0&&flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int Max=200100;
int n,m;
int a[Max];
int vis[Max];
int number;
stack<int>temp;
vector<int>ans;
int main()
{
    while(scanf("%d%d",&n,&m)!=-1)
    {
        number=1;
        ans.clear();
        memset(vis,0,sizeof(vis));
        memset(a,0,sizeof(a));
        for(int i=1; i<=m; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            temp.push(a[i]);
            while(temp.empty()==0&&temp.top()==number)
            {
                temp.pop();
                number++;
            }
        }
        //cout<<1<<endl;
        if(temp.empty()==1)
        {
            for(int i=n; i>=1; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                }
            }
            //cout<<1<<endl;
        }
        int flag=1;
        while(temp.empty()==0)
        {
            for(int i=temp.top(); i>=flag; i--)
            {
                if(vis[i]==0)
                {
                    ans.push_back(i);
                    vis[i]=1;
                }
            }
            flag=temp.top();
            temp.pop();
            if(temp.empty()==1)
            {
                break;
            }
            if(flag>temp.top())
            {
                printf("-1\n");
                return 0;
            }
        }
        for(int i=1; i<=m; i++)
        {
            if(i==1)
            {
                printf("%d",a[i]);
            }
            else
            {
                printf(" %d",a[i]);
            }
        }
        for(int i=0; i<ans.size(); i++)
        {
            printf(" %d",ans[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k;
const int N = 2e5+20;
int a[N];
stack<int> s;
int main()
{
	scanf("%d%d",&n,&k);
	int last = 0;
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&a[i]);
		if(!s.empty() && s.top()<a[i])return !printf("-1\n");
		else s.push(a[i]);
		while(!s.empty() && s.top()==last+1)
		{
			s.pop();
			last++;
		}
	}
	for(int i=1;i<=k;i++)printf("%d ",a[i]);
	if(s.empty())
	{
		for(int i=n;i>last;i--)printf("%d ",i);
		return 0;
	}
	while(!s.empty())
	{
		for(int i=s.top()-1;i>last;i--)printf("%d ",i);
		last = s.top();
		s.pop();
	}
	for(int i=n;i>last;i--)printf("%d ",i);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k;
const int N = 2e5+20;
int a[N];
stack<int> s;
int main()
{
	scanf("%d%d",&n,&k);
	int last = 0;
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&a[i]);
		if(!s.empty() && s.top()<a[i])return !printf("-1\n");
		else s.push(a[i]);
		while(!s.empty() && s.top()==last+1)
		{
			s.pop();
			last++;
		}
	}
	for(int i=1;i<=k;i++)printf("%d ",a[i]);
	if(s.empty())
	{
		for(int i=n;i>last;i++)printf("%d ",i);
		return 0;
	}
	while(!s.empty())
	{
		for(int i=s.top()-1;i>last;i--)printf("%d ",i);
		last = s.top();
		s.pop();
	}
	for(int i=n;i>last;i--)printf("%d ",i);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k;
const int N = 2e5+20;
int a[N],ans[N];
int main()
{
	scanf("%d%d",&n,&k);
	if(k==0)
	{
		for(int i=1;i<=n;i++) printf("%d ",n-i+1);
		return 0;
	}
	for(int i=1;i<=k;i++)
		scanf("%d",&a[i]),ans[i]=a[i];
	int cnt = k;
	for(int i=2;i<=k;i++)if(a[i-1]<a[i])return !printf("-1\n");
	for(int i=k+1;i>=1;i--)
		for(int j=a[i-1]-1;j>a[i];j--)ans[++cnt] = j;
	for(int i=n;i>a[1];i--) ans[++cnt] =i ;
	for(int i=1;i<=cnt;i++)printf("%d ",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
priority_queue<int> s;
set<int> s1;
set<int> :: iterator it;
int n,k;
const int N = 2e5+20;
int a[N],flag[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%d",&a[i]),s.push(a[i]),flag[a[i]]=1;
	int cnt = k;
	for(int i=1;i<=n;i++)if(!flag[i])s1.insert(i);
	for(int i=2;i<=k;i++)if(a[i-1]<a[i])return !printf("-1\n");
	for(int i=1;i<=n;i++)
	{
		if(s.size())
		{
			int x=s.top();
			it = s1.lower_bound(x);
			if(it==s1.begin())s.pop();
			else
			{
				it--;
				a[++cnt] = *it;
				s1.erase(it);
			}
		}
		else
		{
			a[++cnt] = (*(--s1.end()));
			s1.erase(a[cnt]);
		}
	}
	for(int i=1;i<=cnt;i++)printf("%d ",a[i]);
	return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    int x = 1;
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    if(ar[i-1]==x) continue;
                    x++;
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n+1;
    int x = k-1;
    for(int i = 1;i<=x+1;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    int ind = -1;
    for(int i = 1;i<=n;i++){
        if(mark[i]==1){
            ind = i-1;
            break;
        }
    }
    k++;
    while(ind>=1){
        ar[k++] = ind;
        update(ind,1,N-1);
        ind--;
    }
    while(k<=n){

        int ind = go(1,n);

            ar[k++] =ind;
        update(ind,1,N-1);

    }
    for(int i =1;i<=n;i++){
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n+1;
    int x = k-1;
    for(int i = 1;i<=x+1;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    return b;
}
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    int ind = -1;
    for(int i = 1;i<=n;i++){
        if(mark[i]==1){
            ind = i-1;
            break;
        }
    }
    k++;
    while(ind>=1){
        ar[k++] = ind;
        update(ind,1,N-1);
        ind--;
    }
    while(k<=n){

        int ind = go(1,n);
        debug(ind);
        if(ind==k){
            for(int i = n;i>=ind;i--){
                ar[k++]=i;
            }
            break;
        } else {
            ar[k++] =ind;
        }
        update(ind,1,N-1);

    }
    for(int i =1;i<=n;i++){
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}

int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    int x = 1;
    set<int> st;
    for(int i = 1;i<=k;i++) {
        update(ar[i],1,N-1);
        st.insert(ar[i]);
        auto it = st.lower_bound(ar[i]);
        int val = *st.begin();
        int val1 = *it;
        int check = 0;
        if(val==val1) continue;
        check = *--it;
        if(query(check)!=check) {
            cout<<-1<<endl;
            return 0;
        }

    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n+1;
     x = k-1;
    for(int i = 1;i<=x+1;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    int x = 1;
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    if(ar[i-1]==x) continue;
                    x++;
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n+1;
    x = k-1;
    for(int i = 1;i<=x+1;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n;
    int x = k-1;
    for(int i = 1;i<=x;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    int n = e;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    int q = query(b);
    b = 1;
    e = n;
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==q) b = mid+1;
        else e = mid-1;

    }
    return b-1;
}
int br[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    int x = 1;
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    if(ar[i-1]==x) { x++;continue;}

                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    for(int i = 1;i<=k;i++) {
        br[i] = ar[i];
    }
    sort(br+1,br+k+1);
    k++;
    br[k] = n+1;
     x = k-1;
    for(int i = 1;i<=x+1;i++) {
        int x = br[i];
        x--;
        while(x!=br[i-1]) {
            ar[k++] =x;
            x--;
            //debug(x);
        }
    }
    for(int i = 1;i<=n;i++) {
        printf("%d ",ar[i]);
    }

    return 0;
}


//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int tree[N],mark[N];

void update(int idx,int x,int n)
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx+= idx&(-idx);
    }
}
ll query(int idx){
     ll sum=0;
     while(idx>0)
     {
         sum+=tree[idx];idx-=idx&(-idx);
     }
   return sum;
}
int go(int b,int e){
    while(b<=e){
        int mid = (b+e)/2;
        if(query(mid)==mid) b = mid+1;
        else e = mid-1;

    }
    return b;
}
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n = nxt();
    int k = nxt();
    for(int i = 1;i<=k;i++) {
        ar[i] = nxt();
    }
    for(int i = 1;i<=k;i++) {
            mark[ar[i]]=1;
        if(i==1){
            update(ar[i],1,N-1);
        } else {
            update(ar[i],1,N-1);
            if(ar[i]>ar[i-1]){
                int q =query(ar[i]);
                debug(q);
                if(q!=ar[i]){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }
    int ind = -1;
    for(int i = 1;i<=n;i++){
        if(mark[i]==1){
            ind = i-1;
            break;
        }
    }
    k++;
    while(ind>=1){
        ar[k++] = ind;
        update(ind,1,N-1);
        ind--;
    }
    while(k<=n){

        int ind = go(1,n);

        if(ind==k){
            for(int i = n;i>=ind;i--){
                ar[k++]=i;
            }
            break;
        } else {
            ar[k++] =ind;
        }

    }
    for(int i =1;i<=n;i++){
        printf("%d ",ar[i]);
    }

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 200000 + 11;
int N, M, T, P, Q, K;
int kase = 0;
int pre[maxn];
stack<int> ans;
bool check(int l, int r, int pos){
    if (pos == K) {
        for (int i = l; i <= r; i++) ans.push(i);
        return 1;
    }
    int cur = pre[pos];
    if (cur < l || cur > r) return 0;
    else {
        for (int i = cur + 1; i <= r; i++) ans.push(i);
        bool ok = check(l, cur - 1, pos + 1);
        ans.push(cur);
        return ok;
    }
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < K; i++) scanf("%d", &pre[i]);
    bool ok = check(1, N, 0);
    if (ok) { while (!ans.empty()) printf("%d ", ans.top()), ans.pop();}
    else {printf("-1\n"); }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1;
int n,k,a[N],t=1;
stack<int>s;
int main(){
	cin>>n>>k;
	s.push(n+1);
	for(int i=0;i<n;i++){
		if(i<k)cin>>a[i];
		else a[i]=s.top()-1;
		s.push(a[i]);
		while(s.size()&&s.top()==t)s.pop(),t++;
	}
	if(s.size())puts("-1");
	else for(int i=0;i<n;i++)cout<<a[i]<<' ';
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 200000 + 11;
int N, M, T, P, Q, K;
int kase = 0;
int pre[maxn];
vector<int> ans;
bool check(int l, int r, int pos){
    if (pos == K) {
        for (int i = l; i <= r; i++) ans.insert(ans.begin(), i);
        return 1;
    }
    int cur = pre[pos];
    if (cur < l || cur > r) return 0;
    else {
        for (int i = cur + 1; i <= r; i++) ans.insert(ans.begin(), i);
        bool ok = check(l, cur - 1, pos + 1);
        ans.insert(ans.begin(), cur);
        return ok;
    }
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < K; i++) scanf("%d", &pre[i]);
    bool ok = check(1, N, 0);
    if (ok) { for (int i = 0; i < ans.size(); i++) printf("%d ",ans[i]);}
    else {printf("-1\n"); }
    cout << endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 200000 + 11;
int N, M, T, P, Q, K;
int kase = 0;
int ans[maxn], pre[maxn]; bool vis[maxn];
int main()
{
    cin >> N >> K;
    for (int i = 1; i <= K; i++) scanf("%d", &ans[i]), vis[pre[i] = ans[i]] = 1;
    int p = K + 1; ans[0] = 0;
    sort(pre + 1, pre + K); reverse(pre + 1, pre + K);
    for (int q = K; q >= 1; q--) {
        for (int i = pre[q]; i > 0; i--){
            //printf("(%d,%d)\n",q,i);
            if(!vis[i]) ans[p++] = i, vis[i] = 1;
        }
    }
    for (int i = N; i > 0; i--){
        if(!vis[i]) ans[p++] = i, vis[i] = 1;
    }
//    check
    stack<int> st; int cur = 1;
    for (int i = 1; i <= N; i++){
        if (ans[i] != cur) st.push(ans[i]);
        else cur++;
        while (!st.empty() && st.top() == cur) st.pop(), cur++;
    }
    if (st.size()) printf("-1");
    else for (int i = 1; i <= N; i++) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 200000 + 11;
int N, M, T, P, Q, K;
int kase = 0;
int ans[maxn], pre[maxn]; bool vis[maxn];
int main()
{
    cin >> N >> K;
    for (int i = 1; i <= K; i++) scanf("%d", &ans[i]), vis[pre[i] = ans[i]] = 1;
    int p = K + 1; pre[0] = 0; pre[K + 1] = 0;
    sort(pre + 1, pre + K); reverse(pre + 1, pre + K);
    for (int q = K; q >= 1; q--) {
        for (int i = pre[q]; i > max(0, pre[q + 1]); i--){
            //printf("(%d,%d)\n",q,i);
            if(!vis[i]) ans[p++] = i, vis[i] = 1;
        }
    }
    for (int i = N; i > 0; i--){
        if(!vis[i]) ans[p++] = i, vis[i] = 1;
    }
//    check
    stack<int> st; int cur = 1;
    for (int i = 1; i <= N; i++){
        if (ans[i] != cur) st.push(ans[i]);
        else cur++;
        while (!st.empty() && st.top() == cur) st.pop(), cur++;
    }
    if (st.size()) printf("-1");
    else for (int i = 1; i <= N; i++) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+100;
stack<int>s;
int n,k;
int p[maxn];
int main()
{
	scanf("%d%d",&n,&k);
	s.push(n+1);
	int cnt=1;
	for(int i=1;i<=k;i++){
		scanf("%d",&p[i]);
		s.push(p[i]);
		while(s.top()==cnt){
			s.pop();
			cnt++;
		}
	}
	for(int i=k+1;i<=n;i++){
		if(s.top()!=cnt){
			p[i]=s.top()-1;
			s.push(s.top()-1);
		}
		while(s.top()==cnt&&s.top()<=n){
			s.pop();
			cnt++;
		}
	}
	if(cnt>n){
		for(int i=1;i<=n;i++)
			printf("%d ",p[i]);
		printf("\n");
	}else{
		printf("-1\n");
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    p.first = 1, p.second = a[0] - 1, s.insert(p);
    p.first = a[0] + 1, p.second = n, s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        int leftb = swap->first, rightb = swap->second;
        p.first = leftb, p.second = a[i] - 1, s.insert(p);
        p.first = a[i] + 1, p.second = rightb, s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    if(a[0] - 1 >= 1) p.first = 1, p.second = a[0] - 1, s.insert(p);
    if(n >= a[0] + 1) p.first = a[0] + 1, p.second = n, s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        if(a[i] - 1 >= s.begin()->first) p.first = s.begin()->first, p.second = a[i] - 1, s.insert(p);
        if(s.begin()->second >= a[i] + 1) p.first = a[i] + 1, p.second = s.begin()->second, s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
stack<int> s;
map<int,int> m;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) m[i] = 1;
    for(int i = 1, index = 0; i <= n; i++){
        if(m[i] == 1){
        //array
            for(; a[index] != i && a[index] != 0;) s.push(a[index]), m[a[index]] = 0, index++;
            if(a[index] == 0){
                int start = i, end = i;
                for(; i <= n && m[i] == 1; i++, end++);
                i--;
                for(int j = end - 1; j >= start; j--) a[index] = j, m[a[index]] = 0, index++;
            }
            else m[a[index]] = 0, index++;
        }else{
        //stack
            if(s.empty() || s.top() != i){puts("-1"); return 0;}
            else s.pop();
        }
    }
    for(int i = 0; i < n; i++)  printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    p.first = 1, p.second = a[0] - 1;
    s.insert(p);
    p.first = a[0] + 1, p.second = n;
    s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        p.first = s.begin()->first, p.second = a[i] - 1;
        s.insert(p);
        p.first = a[i] + 1, p.second = s.begin()->second;
        s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        if(i->second != i->first)
            for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    if(a[0] - 1 >= 1) p.first = 1, p.second = a[0] - 1, s.insert(p);
    if(n >= a[0] + 1) p.first = a[0] + 1, p.second = n, s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        int leftb = swap->first, rightb = swap->second;
        if(a[i] - 1 >= leftb) p.first = leftb, p.second = a[i] - 1, s.insert(p);
        if(rightb >= a[i] + 1) p.first = a[i] + 1, p.second = rightb, s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    p.first = 1, p.second = a[0] - 1;
    s.insert(p);
    p.first = a[0] + 1, p.second = n;
    s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        p.first = s.begin()->first, p.second = a[i] - 1;
        s.insert(p);
        p.first = a[i] + 1, p.second = s.begin()->second;
        s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
multiset< pair<int,int> > s;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    pair<int,int> p;
    p.first = 1, p.second = a[0] - 1;
    s.insert(p);
    p.first = a[0] + 1, p.second = n;
    s.insert(p);
    for(int i = 1; i < k; i++){
        if(a[i] > s.begin()->second || a[i] < s.begin()->first){ puts("-1"); return 0;}
        multiset< pair<int,int> >::iterator swap = s.begin();
        p.first = s.begin()->first, p.second = a[i] - 1;
        s.insert(p);
        p.first = a[i] + 1, p.second = s.begin()->second;
        s.insert(p);
        s.erase(swap);
    }
    for(int i = 0; i < k; i++) printf("%d ", a[i]);
    for(multiset< pair<int,int> >::iterator i = s.begin(); i != s.end(); i++)
        for(int j = i->second; j >= i->first; j--) printf("%d ", j);
    puts("\n");
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#define MAXN 2e5
using namespace std;

vector<int> a(MAXN, 0);
stack<int> s;
map<int,int> m;

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < k; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) m[i] = 1;
    for(int i = 1, index = 0; i <= n; i++){
        if(m[i] == 1){
        //array
            for(; a[index] != i && a[index] != 0;) s.push(a[index]), m[a[index]] = 0, index++;
            if(a[index] == 0) a[index] = i;
            m[a[index]] = 0, index++;
        }else{
        //stack
            if(s.empty() || s.top() != i){puts("-1"); return 0;}
            else s.pop();
        }
    }
    for(int i = 0; i < n; i++)  printf("%d ", a[i]);
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<double> CPX;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,I> PDI;
typedef pair<LD,I> PLDI;
typedef pair<LL,I> PLLI;
typedef tree<
PII,
null_type,
greater<PII>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef set<I> SI;
typedef set<LL> SL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define sz(v) ((I)(v).size())
#define ifor(i,st,ed) for(I i=(st);i<=(ed);++i)
#define dfor(i,st,ed) for(I i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,n) sort((x),(x)+(n))
#define srtl(x,n,l) sort(all(x),(l))
#define srtnl(x,n,l) sort((x),(x)+(n),(l))
#define cout(x) cout<<fixed<<setprecision((x))
#define pln1(a) cout<<a<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<a<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int N=2e5+7;
int x[N];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=k;++i)cin>>x[i];
  int nxt=1;int mx;
  for(int i=1;i<=k;)
  {
    int j=i;
    mx=x[j];
    while(j<=k&&x[j]!=nxt)
    {
      mx=max(mx,x[j]);
      if(j>i&&x[j]!=x[j-1]-1)
      {
        cout<<"-1\n";
        return 0;
      }
      ++j;
    }
    //~ cerr << " J " << j << endl;
    if(j<=k)
    {
      if(j>i&&x[j]!=x[j-1]-1)
      {
        cout<<"-1\n";
        return 0;
      }
      mx=max(mx,x[j]);
      nxt=mx+1;
    }
    i=j+1;
  }
  for(int i=1;i<=k;++i)
    cout << x[i] << " \0"[i==k];
  for(int i=x[k]-1;i>=nxt;--i)
    cout << i << " \0"[i==nxt];
  for(int i=n;i>=mx+1;--i)
    cout << i << " \n"[i==mx+1];
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<double> CPX;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,I> PDI;
typedef pair<LD,I> PLDI;
typedef pair<LL,I> PLLI;
typedef tree<
PII,
null_type,
greater<PII>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef set<I> SI;
typedef set<LL> SL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define sz(v) ((I)(v).size())
#define ifor(i,st,ed) for(I i=(st);i<=(ed);++i)
#define dfor(i,st,ed) for(I i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,n) sort((x),(x)+(n))
#define srtl(x,n,l) sort(all(x),(l))
#define srtnl(x,n,l) sort((x),(x)+(n),(l))
#define cout(x) cout<<fixed<<setprecision((x))
#define pln1(a) cout<<a<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<a<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int N=2e5+7;
int x[N];
int n,k;
bool sstorable(int i,int j,int lo,int hi)
{
  //~ cerr << " D " << i << ' ' << j << ' ' << lo << ' ' << hi << endl;
  if(j-i!=hi-lo)return false;
  if(i>k)
  {
    while(i<=j)
    {
      x[i]=hi--;
      ++i;
    }
    return true;
  }
  if(lo==hi&&x[i]==lo)return true;
  if(x[i]>hi||x[i]<lo)return false;
  int m=x[i];
  bool ss1=sstorable(i+1,i+m-lo,lo,m-1);
  bool ss2=sstorable(i+m-lo+1,j,m+1,hi);
  return ss1&&ss2;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  cin>>n>>k;
  for(int i=1;i<=k;++i)cin>>x[i];
  if(!sstorable(1,n,1,n))
    cout<<"-1\n";
  else for(int i=1;i<=n;++i)cout << x[i] << " \n"[i==n];
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<double> CPX;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,I> PDI;
typedef pair<LD,I> PLDI;
typedef pair<LL,I> PLLI;
typedef tree<
PII,
null_type,
greater<PII>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef set<I> SI;
typedef set<LL> SL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define sz(v) ((I)(v).size())
#define ifor(i,st,ed) for(I i=(st);i<=(ed);++i)
#define dfor(i,st,ed) for(I i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,n) sort((x),(x)+(n))
#define srtl(x,n,l) sort(all(x),(l))
#define srtnl(x,n,l) sort((x),(x)+(n),(l))
#define cout(x) cout<<fixed<<setprecision((x))
#define pln1(a) cout<<a<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<a<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int N=2e5+7;
int x[N];
int n,k;
bool sstorable(int i,int j,int lo,int hi)
{
  //cerr << " D " << i << ' ' << j << ' ' << lo << ' ' << hi << endl;
  if(j-i!=hi-lo)return false;
  if(i>k)
  {
    while(i<=j)
    {
      x[i]=hi--;
      ++i;
    }
    return true;
  }
  if(lo==hi&&x[i]==lo)return true;
  if(x[i]>hi||x[i]<lo)return false;
  int m=x[i];
  bool ss1=m-lo>0?sstorable(i+1,i+m-lo,lo,m-1):true;
  bool ss2=m-lo>0?sstorable(i+m-lo+1,j,m+1,hi):sstorable(i+1,j,m+1,hi);
  return ss1&&ss2;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  cin>>n>>k;
  for(int i=1;i<=k;++i)cin>>x[i];
  if(!sstorable(1,n,1,n))
    cout<<"-1\n";
  else for(int i=1;i<=n;++i)cout << x[i] << " \n"[i==n];
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<double> CPX;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,I> PDI;
typedef pair<LD,I> PLDI;
typedef pair<LL,I> PLLI;
typedef tree<
PII,
null_type,
greater<PII>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef set<I> SI;
typedef set<LL> SL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define sz(v) ((I)(v).size())
#define ifor(i,st,ed) for(I i=(st);i<=(ed);++i)
#define dfor(i,st,ed) for(I i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,n) sort((x),(x)+(n))
#define srtl(x,n,l) sort(all(x),(l))
#define srtnl(x,n,l) sort((x),(x)+(n),(l))
#define cout(x) cout<<fixed<<setprecision((x))
#define pln1(a) cout<<a<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<a<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int N=2e5+7;
int x[N];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=k;++i)cin>>x[i];
  int nxt=1;int mx;
  for(int i=1;i<=k;)
  {
    int j=i;
    mx=x[j];
    while(j<=k&&x[j]!=nxt)
    {
      mx=max(mx,x[j]);
      if(j>i&&x[j]!=x[j-1]-1)
      {
        cout<<"-1\n";
        return 0;
      }
      ++j;
    }
    //~ cerr << " J " << j << endl;
    if(j<=k)
    {
      if(j>i&&x[j]!=x[j-1]-1)
      {
        cout<<"-1\n";
        return 0;
      }
      mx=max(mx,x[j]);
      nxt=mx+1;
    }
    i=j+1;
  }
  cout << x[1];
  for(int i=2;i<=k;++i)
    cout << " " << x[i];
  for(int i=x[k]-1;i>=nxt;--i)
    cout << " " << i;
  for(int i=n;i>=mx+1;--i)
    cout << " " << i ;
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<double> CPX;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,I> PDI;
typedef pair<LD,I> PLDI;
typedef pair<LL,I> PLLI;
typedef tree<
PII,
null_type,
greater<PII>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef set<I> SI;
typedef set<LL> SL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define sz(v) ((I)(v).size())
#define ifor(i,st,ed) for(I i=(st);i<=(ed);++i)
#define dfor(i,st,ed) for(I i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,n) sort((x),(x)+(n))
#define srtl(x,n,l) sort(all(x),(l))
#define srtnl(x,n,l) sort((x),(x)+(n),(l))
#define cout(x) cout<<fixed<<setprecision((x))
#define pln1(a) cout<<a<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<a<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int N=2e5+7;
int x[N];
int n,k;
bool sstorable(int i,int j,int lo,int hi)
{
  //cerr << " D " << i << ' ' << j << ' ' << lo << ' ' << hi << endl;
  if(j-i!=hi-lo)return false;
  if(i>k)
  {
    while(i<=j)
    {
      x[i]=hi--;
      ++i;
    }
    return true;
  }
  if(lo==hi&&x[i]==lo)return true;
  if(x[i]>hi||x[i]<lo)return false;
  int m=x[i];
  bool ss1=m-lo>0?sstorable(i+1,i+m-lo,lo,m-1):true;
  bool ss2;
  if(m-lo>0)
  {
    if(i+m-lo+1<=j)ss2=sstorable(i+m-lo+1,j,m+1,hi);
    else ss2=true;
  }else
  {
    if(i+1<=j)ss2=sstorable(i+1,j,m+1,hi);
    else ss2=true;
  }
  return ss1&&ss2;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  cin>>n>>k;
  for(int i=1;i<=k;++i)cin>>x[i];
  if(!sstorable(1,n,1,n))
    cout<<"-1\n";
  else for(int i=1;i<=n;++i)cout << x[i] << " \n"[i==n];
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while('0'>ch||ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return f*x;
}
int n,m,k,x,y,vis[200005],a[200005],ans[200005];
stack<int> s;
signed main(){
	n=read();
	m=read();
	x=1;
	for(int i=1;i<=m;i++){
		a[i]=read();
		ans[i]=a[i];
		vis[a[i]]=1;
		s.push(a[i]);
	}
	y=n;
	int tmp=m;
	while(!s.empty()){
		while(!s.empty()&&s.top()==x){
			s.pop();
			x++;
		}
		while(!s.empty()&&s.top()!=x){
			if(vis[y]) {
				puts("-1");
				return 0;
			}
			else{
				y=ans[tmp]-1;
			}
			while(vis[y]) y--;
			if(!y){
				puts("-1");
				return 0;
			}
			ans[++tmp]=y;
			vis[y]=1;
			s.push(y);
			y--;
		}
	}
	if(tmp!=n){
		for(int i=n;i>0;i--){
			if(!vis[i]) ans[++tmp]=i;
		}
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while('0'>ch||ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return f*x;
}
int n,m,k,x=1,y,a[200005],vis[200005],tmp;
stack<int> s;
signed main(){
 	n=read();m=read();
	for(int i=1;i<=m;i++){
		a[i]=read();
		vis[a[i]]=1;
		s.push(a[i]);
		while(!s.empty()&&s.top()==x){
			s.pop();
			x++;
		}
	}
	while(!s.empty()&&s.top()>x||n>=x){
		if(!s.empty()) y=s.top();
		else y=n+1;
		for(int i=y-1;i>=x;i--){
			if(vis[i]){
				puts("-1");
				return 0;
			}
			else{
				s.push(i);
				vis[i]=1;
				a[++m]=i;
			}
		}
		while(!s.empty()&&s.top()==x){
			s.pop();
			x++;
		}
	}
	if(!s.empty()) puts("-1");
	else for(int i=1;i<=n;i++) cout<<a[i]<<" ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], st[N], vs[N];

void fail() {
  puts("-1");
  exit(0);
}

int now = 1, top = 0;
void gao() {
  while(st[top] == now) {
    now++;
    top--;
  }
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for(int i = 1; i <= k; ++i) {
    scanf("%d", &a[i]);
    if(a[i] == now) {
      now++;
      while(st[top] == now) now++, top--;
    } else {
      vs[a[i]] = 1;
      if(top && st[top] < a[i]) fail();
      st[++top] = a[i];
    }
  }
  int r = n;
  for(int i = k + 1; i <= n; ++i) {
    while(vs[r]) r--;
    if(top) {
      a[i] = st[top] - 1;
      st[++top] = a[i];
      vs[a[i]] = 1;
      gao();
    } else {
      a[i] = r;
      vs[r] = 1;
      st[++top] = r;
      gao();
    }
  }
  for(int i = 1; i <= n; ++i)
    printf("%d ", a[i]);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define meme(a,b) memset(a,b,sizeof(a))

const int N=2e5+5;
bool vis[N];
int a[N];
stack<int>s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int temp=1;
    for(int i=1;i<=k;i++){
        cin>>a[i];
        vis[a[i]]=true;
        s.push(a[i]);
        while(s.size()&&s.top()==temp){
            s.pop();
            temp++;
        }
    }
    while(s.size()&&s.top()>temp||n+1>temp){
        int t;
        if(s.size())t=s.top();
        else t=n+1;
        for(int i=t-1;i>=temp;i--){
            if(vis[i]){
                cout<<-1<<endl;
                return 0;
            }
            else s.push(i),a[++k]=i,vis[i]=true;
        }
        while(s.size()&&s.top()==temp){
            s.pop();
            temp++;
        }
    }
    if(s.size())cout<<-1<<endl;
    else for(int i=1;i<=n;i++)cout<<a[i]<<' ';
    cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 5000005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=998244353;
const double oula=0.57721566490153286060651209;
using namespace std;

int a[200005];
stack<int>st;

int main(){
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i];
    }
    int k=n-m;
    int pre=0;
    int flag=0;
    for(int i=1;i<=m;i++){
      /*  if(a[i]-pre==1){
            pre++;
        }
        else{
            while(!st.empty()&&st.top()-pre==1){
                st.pop();
                pre++;
            }
            st.push(a[i]);
        }*/
        if(i!=1){
            if((a[i]==a[i-1]+1)&&(a[i-1]!=i-1)) flag=1;
        }
    }
    if(flag==1){
        cout<<-1<<endl;
    }
    else{
        int i=1;
        int co=1;
        while(i<=m){
            if(co!=a[i]){
                st.push(a[i]);
                i++;
            }
            else{
                co++;
                i++;
                while(!st.empty()&&st.top()==co){
                    co++;
                    st.pop();
                }
            }
        }
        while(!st.empty()){
            int tmp=st.top();
            st.pop();
            for(i=tmp-1;i>=co;i--){
                a[++m]=i;
            }
            co=tmp+1;
        }
        for(int i=n;i>=co;i--) a[++m]=i;
        for(int i=1;i<=m;i++){
            cout<<a[i]<<" ";
        }
    }
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 200010;
int n, k;
bool used[MAX_N];
vi arr;

bool stackSortable() {
    stack<int> s;
    vector<int> res;
    M00(i, (int)arr.size()) {
        while(!s.empty() && arr[i] > s.top()) {
            res.PB(s.top());
            s.pop();
        }
        s.push(arr[i]);
    }
    while(!s.empty()) res.PB(s.top()), s.pop();
    M00(i, (int)arr.size()-1) {
        if(res[i] > res[i+1]) return 0;
    }
    return 1;
}

int main() { FAST
    cin >> n >> k;
    M00(i, k) {
        int k; cin >> k;
        used[k] = 1;
        arr.PB(k);
    }
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    }
    int lo = 1000000;
    int hi = 0;
    M00(i, k) {
        hi = max(hi, arr[i]);
        lo = min(lo, arr[i]);
    }
    MOOd(i, lo, hi+1) {
        if(!used[i]) arr.PB(i);
    }
    MOOd(i, 1, lo) arr.PB(i);
    MOOd(i, hi+1, n+1) arr.PB(i);
    if(!stackSortable()) {
        cout << "-1\n";
    } else {
        M00(i, n) {
            cout << arr[i];
            if(i != n-1) cout << " ";
        }
    }
    cout << "\n";
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 200010;
int n, k;
bool used[MAX_N];
vi arr;

bool stackSortable() {
    stack<int> s;
    vector<int> res;
    M00(i, (int)arr.size()) {
        while(!s.empty() && arr[i] > s.top()) {
            res.PB(s.top());
            s.pop();
        }
        s.push(arr[i]);
    }
    while(!s.empty()) res.PB(s.top()), s.pop();
    M00(i, (int)arr.size()-1) {
        if(res[i] > res[i+1]) return 0;
    }
    return 1;
}

int main() { FAST
    cin >> n >> k;
    M00(i, k) {
        int k; cin >> k;
        used[k] = 1;
        arr.PB(k);
    }
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    }
    int lo = 1000000;
    int hi = 0;
    M00(i, k) {
        hi = max(hi, arr[i]);
        lo = min(lo, arr[i]);
    }
    MOOd(i, 1, lo) arr.PB(i);
    MOOd(i, lo, hi+1) {
        if(!used[i]) arr.PB(i);
    }
    MOOd(i, hi+1, n+1) arr.PB(i);
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    } else {
        M00(i, n) {
            cout << arr[i];
            if(i != n-1) cout << " ";
        }
    }
    cout << "\n";
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 200010;
int n, k;
bool used[MAX_N];
vi arr;

bool stackSortable() {
    stack<int> s;
    vector<int> res;
    M00(i, (int)arr.size()) {
        while(!s.empty() && arr[i] > s.top()) {
            res.PB(s.top());
            s.pop();
        }
        s.push(arr[i]);
    }
    while(!s.empty()) res.PB(s.top()), s.pop();
    M00(i, (int)res.size()-1) {
        if(res[i] > res[i+1]) return 0;
    }
    return 1;
}

int main() { FAST
    cin >> n >> k;
    M00(i, k) {
        int k; cin >> k;
        used[k] = 1;
        arr.PB(k);
    }
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    }
    int lo = 1000000;
    int hi = 0;
    M00(i, k) {
        hi = max(hi, arr[i]);
        lo = min(lo, arr[i]);
    }
    MOOd(i, 1, lo) arr.PB(i);
    M00(i, k-1) {
        MOOd(j, arr[i]+1, arr[i+1]) arr.PB(j);
    }
    MOOd(i, hi+1, n+1) arr.PB(i);
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    } else {
        M00(i, n) {
            cout << arr[i];
            if(i != n-1) cout << " ";
        }
    }
    cout << "\n";
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 200010;
int n, k;
bool used[MAX_N];
vi arr;

bool stackSortable() {
    stack<int> s;
    vector<int> res;
    M00(i, (int)arr.size()) {
        while(!s.empty() && arr[i] > s.top()) {
            res.PB(s.top());
            s.pop();
        }
        s.push(arr[i]);
    }
    while(!s.empty()) res.PB(s.top()), s.pop();
    M00(i, (int)res.size()-1) {
        if(res[i] > res[i+1]) return 0;
    }
    return 1;
}

int main() { FAST
    cin >> n >> k;
    M00(i, k) {
        int k; cin >> k;
        used[k] = 1;
        arr.PB(k);
    }
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    }
    int lo = 1000000;
    int hi = 0;
    M00(i, k) {
        hi = max(hi, arr[i]);
        lo = min(lo, arr[i]);
    }
    MOOd(i, 1, lo) arr.PB(i);
    vi arr2;
    M00(i, k) arr2.PB(arr[i]);
    sort(arr2.begin(), arr2.end());
    M00(i, k-1) {
        MOOd(j, arr2[i]+1, arr2[i+1]) arr.PB(j);
    }
    MOOd(i, hi+1, n+1) arr.PB(i);
    if(!stackSortable()) {
        cout << "-1\n";
        return 0;
    } else {
        M00(i, n) {
            cout << arr[i];
            if(i != n-1) cout << " ";
        }
    }
    cout << "\n";
}


#include <iostream>
#include <stack>
using namespace std;
const int MAXN = 200000 + 10;
int s[MAXN], nums[MAXN];
bool vis[MAXN];
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k, cur = 1, idx = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &nums[i]);
        vis[nums[i]] = true;
        if (nums[i] == cur) {
            cur++;
            while (idx > 0 && s[idx-1] == cur) {
                cur++;
                idx--;
            }
        }
        else {
            s[idx++] = nums[i];
        }
    }
    for (int i = 0; i+1 < idx; i++) {
        if (s[i] < s[i+1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int m = n;
    for (int i = 0; i < k; i++) {
        printf("%d", nums[i]); m--;
        if (m > 0) printf(" ");
        else printf("\n");
    }
    idx = 1;
    stack<int> ret;
    while (m > 0) {
        while (idx <= n && vis[idx]) idx++;
        while(idx <= n && !vis[idx]) ret.push(idx++);
        while (!ret.empty()) {
            printf("%d", ret.top()); ret.pop(); m--;
            if (m > 0) printf(" ");
            else printf("\n");
        }
    }

    return 0;
}


#include <iostream>
#include <stack>
using namespace std;
const int MAXN = 200000 + 10;
int s[MAXN], nums[MAXN];
bool vis[MAXN];
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k, cur = 1, idx = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &nums[i]);
        vis[nums[i]] = true;
        if (nums[i] == cur) cur++;
        else {
            s[idx++] = nums[i];
        }
    }
    for (int i = 0; i+1 < idx; i++) {
        if (s[i] < s[i+1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int m = n;
    for (int i = 0; i < k; i++) {
        printf("%d", nums[i]); m--;
        if (m > 0) printf(" ");
        else printf("\n");
    }
    idx = 1;
    stack<int> ret;
    while (m > 0) {
        while (idx <= n && vis[idx]) idx++;
        while(idx <= n && !vis[idx]) ret.push(idx++);
        while (!ret.empty()) {
            printf("%d", ret.top()); ret.pop(); m--;
            if (m > 0) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <stack>
using namespace std;
const int MAXN = 200000 + 10;
int s[MAXN], nums[MAXN];
bool vis[MAXN];
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k, cur = 1, idx = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &nums[i]);
        vis[nums[i]] = true;
        if (nums[i] == cur) {
            cur++;
            while (idx > 0 && nums[idx-1] == cur) {
                cur++;
                idx--;
            }
        }
        else {
            s[idx++] = nums[i];
        }
    }
    for (int i = 0; i+1 < idx; i++) {
        if (s[i] < s[i+1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int m = n;
    for (int i = 0; i < k; i++) {
        printf("%d", nums[i]); m--;
        if (m > 0) printf(" ");
        else printf("\n");
    }
    idx = 1;
    stack<int> ret;
    while (m > 0) {
        while (idx <= n && vis[idx]) idx++;
        while(idx <= n && !vis[idx]) ret.push(idx++);
        while (!ret.empty()) {
            printf("%d", ret.top()); ret.pop(); m--;
            if (m > 0) printf(" ");
            else printf("\n");
        }
    }

    return 0;
}


#include <iostream>
#include <stack>
using namespace std;
const int MAXN = 200000 + 10;
int s[MAXN], nums[MAXN];
bool vis[MAXN];
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k, cur = 1, idx = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &nums[i]);
        vis[nums[i]] = true;
        if (nums[i] == cur) cur++;
        else {
            s[idx++] = nums[i];
        }
    }
    for (int i = 0; i+1 < idx; i++) {
        if (s[i] < s[i+1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int m = n;
    for (int i = 0; i < k; i++) {
        printf("%d", nums[i]); m--;
        if (m > 0) printf(" ");
        else printf("\n");
    }
    idx = 1;
    stack<int> ret;
    while (m > 0) {
        while (idx <= n && vis[idx]) idx++;
        while(idx <= n && !vis[idx]) ret.push(idx++);
        while (!ret.empty()) {
            printf("%d", ret.top()); ret.pop(); m--;
            if (m > 0) printf(" ");
            else printf("\n");
        }
    }

    return 0;
}