#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[200005],tt[800005],vis[200005],l[200005],ans[800005],lz[800005];
void up(int rt)
{
	tt[rt]=min(tt[rt<<1],tt[rt<<1|1]);
	return;
}
void bt(int rt,int ll,int rr)
{
	if(ll==rr)
	{
		if(a[ll]) tt[rt]=a[ll];
		else tt[rt]=q;
		return;
	}
	int mid=(ll+rr)>>1;
	bt(rt<<1,ll,mid);
	bt(rt<<1|1,mid+1,rr);
	up(rt);
	return;
}
int query(int rt,int ll,int rr,int L,int R)
{
	if(ll==L&&rr==R) return tt[rt];
	int mid=(ll+rr)>>1;
	if(R<=mid) return query(rt<<1,ll,mid,L,R);
	else if(L>mid) return query(rt<<1|1,mid+1,rr,L,R);
	else return min(query(rt<<1,ll,mid,L,mid),query(rt<<1|1,mid,rr,mid+1,R));
}
void push(int rt)
{
	if(!lz[rt]) return;
	lz[rt<<1]=max(lz[rt<<1],lz[rt]);
	lz[rt<<1|1]=max(lz[rt<<1|1],lz[rt]);
	ans[rt<<1]=max(ans[rt<<1],lz[rt]);
	ans[rt<<1|1]=max(ans[rt<<1|1],lz[rt]);
	lz[rt]=0;
	return;
}
void update(int rt,int ll,int rr,int L,int R,int kk)
{
	if(ll==L&&rr==R)
	{
		ans[rt]=max(ans[rt],kk);
		lz[rt]=max(kk,lz[rt]);
		return;
	}
	int mid=(ll+rr)>>1;
	push(rt);
	if(R<=mid) update(rt<<1,ll,mid,L,R,kk);
	else if(L>mid) update(rt<<1|1,mid+1,rr,L,R,kk);
	else update(rt<<1,ll,mid,L,mid,kk),update(rt<<1|1,mid+1,rr,mid+1,R,kk);
	ans[rt]=max(ans[rt<<1],ans[rt<<1|1]);
	return;
}
int getans(int rt,int ll,int rr,int dd)
{
	if(ll==rr) return ans[rt];
	int mid=(ll+rr)>>1;
	push(rt);
	if(dd<=mid) return getans(rt<<1,ll,mid,dd);
	else return getans(rt<<1|1,mid+1,rr,dd);
}
int main()
{
	scanf("%d%d",&n,&q);
	int mn=q;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]) mn=min(mn,a[i]);
		if(!vis[a[i]]) l[a[i]]=i;
		vis[a[i]]=i;
	}
	bt(1,1,n);
	update(1,1,n,1,n,mn);
	for(int i=1;i<=q;++i)
	{
		int mx=0;
		if(vis[i])
		{
			mx=query(1,1,n,l[i],vis[i]);
			if(mx<i) {puts("NO");return 0;}
			update(1,1,n,l[i],vis[i],i);
		}
	}
	puts("YES");
	for(int i=1;i<=n;++i)
	printf("%d ",getans(1,1,n,i));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[200005],tt[800005],vis[200005],l[200005],ans[800005],lz[800005];
void up(int rt)
{
	tt[rt]=min(tt[rt<<1],tt[rt<<1|1]);
	return;
}
void bt(int rt,int ll,int rr)
{
	if(ll==rr)
	{
		if(a[ll]) tt[rt]=a[ll];
		else tt[rt]=q;
		return;
	}
	int mid=(ll+rr)>>1;
	bt(rt<<1,ll,mid);
	bt(rt<<1|1,mid+1,rr);
	up(rt);
	return;
}
int query(int rt,int ll,int rr,int L,int R)
{
	if(ll==L&&rr==R) return tt[rt];
	int mid=(ll+rr)>>1;
	if(R<=mid) return query(rt<<1,ll,mid,L,R);
	else if(L>mid) return query(rt<<1|1,mid+1,rr,L,R);
	else return min(query(rt<<1,ll,mid,L,mid),query(rt<<1,ll,mid,mid+1,R));
}
void push(int rt)
{
	if(!lz[rt]) return;
	lz[rt<<1]=max(lz[rt<<1],lz[rt]);
	lz[rt<<1|1]=max(lz[rt<<1|1],lz[rt]);
	ans[rt<<1]=max(ans[rt<<1],lz[rt]);
	ans[rt<<1|1]=max(ans[rt<<1|1],lz[rt]);
	lz[rt]=0;
	return;
}
void update(int rt,int ll,int rr,int L,int R,int kk)
{
	if(ll==L&&rr==R)
	{
		ans[rt]=max(ans[rt],kk);
		lz[rt]=max(kk,lz[rt]);
		return;
	}
	int mid=(ll+rr)>>1;
	push(rt);
	if(R<=mid) update(rt<<1,ll,mid,L,R,kk);
	else if(L>mid) update(rt<<1|1,mid+1,rr,L,R,kk);
	else update(rt<<1,ll,mid,L,mid,kk),update(rt<<1|1,mid+1,rr,mid+1,R,kk);
	ans[rt]=max(ans[rt<<1],ans[rt<<1|1]);
	return;
}
int getans(int rt,int ll,int rr,int dd)
{
	if(ll==rr) return ans[rt];
	int mid=(ll+rr)>>1;
	push(rt);
	if(dd<=mid) return getans(rt<<1,ll,mid,dd);
	else return getans(rt<<1|1,mid+1,rr,dd);
}
int main()
{
	scanf("%d%d",&n,&q);
	int mn=q;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]) mn=min(mn,a[i]);
		if(!vis[a[i]]) l[a[i]]=i;
		vis[a[i]]=i;
	}
	bt(1,1,n);
	update(1,1,n,1,n,mn);
	for(int i=1;i<=q;++i)
	{
		int mx=0;
		if(vis[i])
		{
			mx=query(1,1,n,l[i],vis[i]);
			if(mx<i) {puts("NO");return 0;}
			update(1,1,n,l[i],vis[i],i);
		}
	}
	puts("YES");
	for(int i=1;i<=n;++i)
	printf("%d ",getans(1,1,n,i));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[200005],tt[800005],vis[200005],l[200005],ans[200005];
void up(int rt)
{
	tt[rt]=min(tt[rt<<1],tt[rt<<1|1]);
	return;
}
void bt(int rt,int ll,int rr)
{
	if(ll==rr)
	{
		if(a[ll]) tt[rt]=a[ll];
		else tt[rt]=q;
		return;
	}
	int mid=(ll+rr)>>1;
	bt(rt<<1,ll,mid);
	bt(rt<<1|1,mid+1,rr);
	up(rt);
	return;
}
int query(int rt,int ll,int rr,int L,int R)
{
	if(ll==L&&rr==R) return tt[rt];
	int mid=(ll+rr)>>1;
	if(R<=mid) return query(rt<<1,ll,mid,L,R);
	else if(L>mid) return query(rt<<1|1,mid+1,rr,L,R);
	else return min(query(rt<<1,ll,mid,L,mid),query(rt<<1,ll,mid,mid+1,R));
}
int main()
{
	scanf("%d%d",&n,&q);
	int mn=q;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]) mn=min(mn,a[i]);
		if(!vis[a[i]]) l[a[i]]=i;
		vis[a[i]]=i;
	}
	bt(1,1,n);
	for(int i=1;i<=q;++i)
	{
		int mx=0;
		if(vis[i])
		{
			mx=query(1,1,n,l[i],vis[i]);
			if(mx<i) {puts("NO");return 0;}
		}
	}
	if(a[1]==0) ans[1]=1;
	else ans[1]=a[1];
	for(int i=2;i<=n;++i) if(a[i]==0) ans[i]=ans[i-1];else ans[i]=a[i];
	if(!vis[q])
	{
		int ff=1;
		for(int i=1;i<=n;++i) if(a[i]==0) {ff=0;ans[i]=q;break;}
		if(ff)
		{
			puts("NO");return 0;
		}
	}
	puts("YES");
	for(int i=1;i<=n;++i) printf("%d ",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[200005],tt[800005],vis[200005],l[200005],ans[200005];
void up(int rt)
{
	tt[rt]=min(tt[rt<<1],tt[rt<<1|1]);
	return;
}
void bt(int rt,int ll,int rr)
{
	if(ll==rr)
	{
		if(a[ll]) tt[rt]=a[ll];
		else tt[rt]=q;
		return;
	}
	int mid=(ll+rr)>>1;
	bt(rt<<1,ll,mid);
	bt(rt<<1|1,mid+1,rr);
	up(rt);
	return;
}
int query(int rt,int ll,int rr,int L,int R)
{
	if(ll==L&&rr==R) return tt[rt];
	int mid=(ll+rr)>>1;
	if(R<=mid) return query(rt<<1,ll,mid,L,R);
	else if(L>mid) return query(rt<<1|1,mid+1,rr,L,R);
	else return min(query(rt<<1,ll,mid,L,mid),query(rt<<1|1,mid+1,rr,mid+1,R));
}
int main()
{
	scanf("%d%d",&n,&q);
	int mn=q;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]) mn=min(mn,a[i]);
		if(!vis[a[i]]) l[a[i]]=i;
		vis[a[i]]=i;
	}
	bt(1,1,n);
	for(int i=1;i<=q;++i)
	{
		int mx=0;
		if(vis[i])
		{
			mx=query(1,1,n,l[i],vis[i]);
			if(mx<i) {puts("NO");return 0;}
		}
	}
	if(a[1]==0) ans[1]=1;
	else ans[1]=a[1];
	for(int i=2;i<=n;++i) if(a[i]==0) ans[i]=ans[i-1];else ans[i]=a[i];
	if(!vis[q])
	{
		int ff=1;
		for(int i=1;i<=n;++i) if(a[i]==0) {ff=0;ans[i]=q;break;}
		if(ff)
		{
			puts("NO");return 0;
		}
	}
	puts("YES");
	for(int i=1;i<=n;++i) printf("%d ",ans[i]);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define ltree (o<<1)
#define rtree (o<<1|1)

int odk,n,q,a[200010]={0},tree[1000010]={0},l[200010]={0},r[200010]={0},flag=0;

void pushup(int o) {tree[o]=min(tree[ltree],tree[rtree]);}

void build(int o,int l,int r){
    if(l==r) {tree[o]=a[l]; return;}
    int mid=(l+r)>>1;
    build(ltree,l,mid);
    build(rtree,mid+1,r);
    pushup(o);
}

int query(int o,int l,int r,int ql,int qr){
    if(r<ql || l>qr) return 10000000;
    if(r<=qr && l>=ql) return tree[o];
    int mid=(l+r)>>1;
    return min(query(ltree,l,mid,ql,qr),query(rtree,mid+1,r,ql,qr));
}

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%d",&a[i]); flag=(a[i]==q)?1:flag;}
    if(!flag)
        for(int i=1;i<=n;i++){
            if(!a[i]) {a[i]=q; flag=1; break;}
        }
    if(!flag) printf("NO");
    else{
        if(!a[1]) for(int i=2;i<=n;i++) if(a[i]) {a[1]=a[i]; break;}
        for(int i=2;i<=n;i++) if(!a[i]) a[i]=a[i-1];
        for(int i=1;i<=n;i++) l[a[i]]=l[a[i]]?l[a[i]]:i,r[a[i]]=i;
        build(1,1,n);
        for(int i=1;i<=q;i++){
            if(l[i]!=r[i] && query(1,1,n,l[i],r[i])<i) {printf("NO"); break;}
            if(i==q){
                printf("YES\n");
                for(int i=1;i<=n;i++) printf("%d ",a[i]);
            }
        }
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=0,tag=2,peak=1,last=0,limit=0;

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) {last=i; continue;}
        if(a[i]<limit) tag=0;
        if(tag==2 && a[i]<k) tag--;
        if(tag==1 && a[i]>a[peak]) limit=a[i],tag=2;
        else if(tag==1 && a[i]>k) tag--;
        k=a[i];
        peak=a[i]>a[peak]?i:peak;
    }
    if(!tag) printf("NO");
    else if(a[peak]<q && last==0) printf("NO");
    else {
        printf("YES\n");
        k=1;
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else if(peak<q && i==last) printf("%d ",q);
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=0,tag=2;

int main(){
    cin >> n >> q;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) continue;
        if(tag==2 && a[i]<k) tag--;
        if(tag==1 && a[i]>k) tag--;
        k=a[i];
    }
    if(!tag) printf("NO");
    else {
        printf("YES\n");
        k=1;
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=0,tag=2,peak=1,last;

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) {last=i; continue;}
        peak=a[i]>peak?a[i]:peak;
        if(tag==2 && a[i]<k) tag--;
        if(tag==1 && a[i]>k) tag--;
        k=a[i];
    }
    if(!tag) printf("NO");
    else {
        printf("YES\n");
        k=1;
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else if(peak<q && i==last) printf("%d ",q);
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=0,tag=2,z=1;

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) continue;
        if(tag==2 && a[i]<k) tag--;
        if(tag==1 && a[i]>k) tag--;
        k=a[i];
        z=0;
    }
    if(!tag) printf("NO");
    else {
        printf("YES\n");
        k=1;
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else if(z && i==n) printf("%d ",q);
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define ltree (o<<1)
#define rtree (o<<1|1)

int n,q,a[200010]={0},tree[1000010]={0},l[200010]={0},r[200010]={0},flag=0;

void pushup(int o) {tree[o]=min(tree[ltree],tree[rtree]);}

void build(int o,int l,int r){
    if(l==r) {tree[o]=a[l]; return;}
    int mid=(l+r)>>1;
    build(ltree,l,mid);
    build(rtree,mid+1,r);
    pushup(o);
}

int query(int o,int l,int r,int ql,int qr){
    if(r<ql || l>qr) return 10000000;
    if(r<=qr && l>=ql) return tree[o];
    int mid=(l+r)>>1;
    return min(query(ltree,l,mid,ql,qr),query(rtree,mid+1,r,ql,qr));
}

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%d",&a[i]); flag=(a[i]==q)?1:flag;}
    if(!flag)
        for(int i=1;i<=n;i++){
            if(!a[i]) {a[i]=q; flag=1; break;}
        }
    if(!flag) printf("NO");
    else{
        if(!a[1]) for(int i=2;i<=n;i++) if(a[i]) {a[1]=a[i]; break;}
        for(int i=2;i<=n;i++) if(!a[i]) a[i]=a[i-1];
        for(int i=1;i<=n;i++) l[a[i]]=l[a[i]]?l[a[i]]:i,r[a[i]]=i;
        build(1,1,n);
        for(int i=1;i<=q;i++){
            if(l[i]!=r[i] && query(1,1,n,l[i],r[i])<i) {printf("NO"); break;}
            if(i==q){
                printf("YES\n");
                for(int i=1;i<=n;i++) printf("%d ",a[i]);
            }
        }
    }
    return 0;
}


#include <algorithm>
using namespace std;
#define ltree (o<<1)
#define rtree (o<<1|1)

int n,q,a[200010]={0},tree[1000010]={0},l[200010]={0},r[200010]={0},flag=0,odk;

void pushup(int o) {tree[o]=min(tree[ltree],tree[rtree]);}

void build(int o,int l,int r){
    if(l==r) {tree[o]=a[l]; return;}
    int mid=(l+r)>>1;
    build(ltree,l,mid);
    build(rtree,mid+1,r);
    pushup(o);
}

int query(int o,int l,int r,int ql,int qr){
    if(r<ql || l>qr) return 10000000;
    if(r<=qr && l>=ql) return tree[o];
    int mid=(l+r)>>1;
    return min(query(ltree,l,mid,ql,qr),query(rtree,mid+1,r,ql,qr));
}

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%d",&a[i]); flag=(a[i]==q)?1:flag;}
    if(!flag)
        for(int i=1;i<=n;i++){
            if(!a[i]) {a[i]=q; flag=1; break;}
        }
    if(!flag) printf("NO");
    else{
        if(!a[1]) for(int i=2;i<=n;i++) if(a[i]) {a[1]=a[i]; break;}
        for(int i=2;i<=n;i++) if(!a[i]) a[i]=a[i-1];
        for(int i=1;i<=n;i++) l[a[i]]=l[a[i]]?l[a[i]]:i,r[a[i]]=i;
        build(1,1,n);
        for(int i=1;i<=q;i++){
            if(l[i]!=r[i] && query(1,1,n,l[i],r[i])<i) {printf("NO"); break;}
            if(i==q){
                printf("YES\n");
                for(int i=1;i<=n;i++) printf("%d ",a[i]);
            }
        }
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=0,tag=2,peak=1,last;

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) {last=i; continue;}
        if(tag==2 && a[i]<k) tag--,peak=k;
        if(tag==1 && a[i]>k) tag--;
        k=a[i];
    }
    if(!tag) printf("NO");
    else {
        printf("YES\n");
        k=1;
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else if(peak<q && i==last) printf("%d ",q);
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,q,a[200010],k=1,tag=2;

int main(){
    cin >> n >> q;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n && tag;i++){
        if(!a[i]) continue;
        if(tag==2 && a[i]<k) tag--;
        if(tag==1 && a[i]>k) tag--;
        k=a[i];
    }
    if(!tag) printf("NO");
    else{
        printf("YES\n");
        for(int i=1;i<=n;i++)
            if(a[i]) {printf("%d ",a[i]); k=a[i];}
            else printf("%d ",k);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define ltree (o<<1)
#define rtree (o<<1|1)

int n,q,a[200010]={0},tree[500010]={0},l[200010]={0},r[200010]={0},flag=0;

void pushup(int o) {tree[o]=min(tree[ltree],tree[rtree]);}

void build(int o,int l,int r){
    if(l==r) {tree[o]=a[l]; return;}
    int mid=(l+r)>>1;
    build(ltree,l,mid);
    build(rtree,mid+1,r);
    pushup(o);
}

int query(int o,int l,int r,int ql,int qr){
    if(r<ql || l>qr) return 10000000;
    if(r<=qr && l>=ql) return tree[o];
    int mid=(l+r)>>1;
    return min(query(ltree,l,mid,ql,qr),query(rtree,mid+1,r,ql,qr));
}

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%d",&a[i]); flag=(a[i]==q)?1:flag;}
    if(!flag)
        for(int i=1;i<=n;i++){
            if(!a[i]) {a[i]=q; flag=1; break;}
        }
    if(!flag) printf("NO");
    else{
        if(!a[1]) for(int i=2;i<=n;i++) if(a[i]) {a[1]=a[i]; break;}
        for(int i=2;i<=n;i++) if(!a[i]) a[i]=a[i-1];
        for(int i=1;i<=n;i++) l[a[i]]=l[a[i]]?l[a[i]]:i,r[a[i]]=i;
        build(1,1,n);
        for(int i=1;i<=q;i++){
            if(l[i]!=r[i] && query(1,1,n,l[i],r[i])<i) {printf("NO"); break;}
            if(i==q){
                printf("YES\n");
                for(int i=1;i<=n;i++) printf("%d ",a[i]);
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
//105G
struct Istream {
	Istream() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
		freopen("input","r",stdin);
#else
		std::string fileName(__FILE__),name=fileName.substr(0,fileName.find('.'));
		freopen((name+".in").c_str(),"r",stdin);
		freopen((name+".out").c_str(),"w",stdout);
#endif
#endif
	}
#ifdef OI
	char getchar() {
		static const int IN=1e5;
		static char in[IN],*ip=in,*ie=in;
		return ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie)?EOF:*ip++;
	}
#else
	Istream &operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
#endif
	template <class T>
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}

	Istream &operator >>(char &ch) {
		while(!isalnum(ch=getchar()) && !ispunct(ch));
		return *this;
	}

	Istream &operator >>(char *s) {
		while(!isalnum(*s=getchar()) && !ispunct(*s));
		while(isalnum(*++s=getchar()) || ispunct(*s));
		*s=0;return *this;
	}

	template <class T>
	operator T() {
		static T x;*this>>x;
		return x;
	}
}fin;

struct Ostream {
#ifdef OO
	char out[(int)1e5],*op;

	Ostream():op(out) {}
	~Ostream() {
		flush();
	}

	void flush() {
		fwrite(out,1,op-out,stdout);
	}

	void putchar(char const &x) {
		*op==EOF && (flush(),op=out,*op++);
		*op++=x;
	}
#else
	Ostream &operator <<(double x) {
		printf("%.10lf",x);
		return *this;
	}
#endif
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}

	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}

	Ostream &operator <<(const char *s) {
		while(*s)
			putchar(*s++);
		return *this;
	}
}fout;

template <class T> bool Enlarge(T &a,T const &b) {
	return a<b?a=b,1:0;
}

template <class T> bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11,XLOGN=18;

int st[XN][XLOGN],lg2[XN];
int Min(int l,int r) {
	int lg=lg2[r-l+1];
	return std::min(st[l][lg],st[r-(1<<lg)+1][lg]);
}
int main() {
	int n,m;fin>>n>>m;
	static int a[XN],first[XN],last[XN];
	lg2[0]=-1;
	for(int i=1;i<=n;++i) {
		fin>>a[i];
		if(!first[a[i]])
			first[a[i]]=i;
		last[a[i]]=i;
		lg2[i]=lg2[i>>1]+1;
		st[i][0]=a[i]==0?m+1:a[i];
	}
	for(int lg=1;lg<=lg2[n];++lg)
		for(int i=1;i<=n-(1<<lg)+1;++i)
			st[i][lg]=std::min(st[i][lg-1],st[i+(1<<(lg-1))][lg-1]);
	bool tak=1;
	for(int x=1;x<=m;++x)
		if(first[x] && Min(first[x],last[x])<x) {
			tak=0;
			break;
		}
	if(!first[m]) {
		if(first[0])
			a[first[0]]=m;
		else
			tak=0;
	}
	if(tak) {
		if(a[1]==0) {
			int p=1;
			while(a[p]==0) ++p;//此时必须有一个m了
			for(int i=p;i>=1;--i)
				a[i]=a[i+1];
		}
		puts("YES");
		for(int i=1;i<=n;++i) {
			if(!a[i])
				a[i]=a[i-1];
			fout<<a[i]<<(i==n?'\n':' ');
		}
	} else
		puts("NO");
	return 0;
}


#include <bits/stdc++.h>
//105G
struct Istream {
	Istream() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
		freopen("input","r",stdin);
#else
		std::string fileName(__FILE__),name=fileName.substr(0,fileName.find('.'));
		freopen((name+".in").c_str(),"r",stdin);
		freopen((name+".out").c_str(),"w",stdout);
#endif
#endif
	}
#ifdef OI
	char getchar() {
		static const int IN=1e5;
		static char in[IN],*ip=in,*ie=in;
		return ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie)?EOF:*ip++;
	}
#else
	Istream &operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
#endif
	template <class T>
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}

	Istream &operator >>(char &ch) {
		while(!isalnum(ch=getchar()) && !ispunct(ch));
		return *this;
	}

	Istream &operator >>(char *s) {
		while(!isalnum(*s=getchar()) && !ispunct(*s));
		while(isalnum(*++s=getchar()) || ispunct(*s));
		*s=0;return *this;
	}

	template <class T>
	operator T() {
		static T x;*this>>x;
		return x;
	}
}fin;

struct Ostream {
#ifdef OO
	char out[(int)1e5],*op;

	Ostream():op(out) {}
	~Ostream() {
		flush();
	}

	void flush() {
		fwrite(out,1,op-out,stdout);
	}

	void putchar(char const &x) {
		*op==EOF && (flush(),op=out,*op++);
		*op++=x;
	}
#else
	Ostream &operator <<(double x) {
		printf("%.10lf",x);
		return *this;
	}
#endif
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}

	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}

	Ostream &operator <<(const char *s) {
		while(*s)
			putchar(*s++);
		return *this;
	}
}fout;

template <class T> bool Enlarge(T &a,T const &b) {
	return a<b?a=b,1:0;
}

template <class T> bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11,XLOGN=18;

int st[XN][XLOGN],lg2[XN];
int Min(int l,int r) {
	int lg=lg2[r-l+1];
	return std::min(st[l][lg],st[r-(1<<lg)+1][lg]);
}
int main() {
	int n,m;fin>>n>>m;
	static int a[XN],first[XN],last[XN];
	lg2[0]=-1;
	for(int i=1;i<=n;++i) {
		fin>>a[i];
		if(!first[a[i]])
			first[a[i]]=i;
		last[a[i]]=i;
		lg2[i]=lg2[i>>1]+1;
		st[i][0]=a[i]==0?m+1:a[i];
	}
	for(int lg=1;lg<=lg2[n];++lg)
		for(int i=1;i<=n-(1<<lg)+1;++i)
			st[i][lg]=std::min(st[i][lg-1],st[i+(1<<(lg-1))][lg-1]);
	bool tak=1;
	for(int x=1;x<=m;++x)
		if(first[x] && Min(first[x],last[x])<x) {
			tak=0;
			break;
		}
	if(tak) {
		puts("YES");
		int p=1;while(p<=n && a[p]==0) ++p;
		if(p==n+1)
			a[p+1]=m;
		for(int i=p;i>=1;--i)
			a[i]=a[i+1];
		for(int i=1;i<=n;++i) {
			if(!a[i])
				a[i]=a[i-1];
			fout<<a[i]<<(i==n?'\n':' ');
		}
	} else
		puts("NO");
	return 0;
}


#include <bits/stdc++.h>
//105G
struct Istream {
	Istream() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
		freopen("input","r",stdin);
#else
		std::string fileName(__FILE__),name=fileName.substr(0,fileName.find('.'));
		freopen((name+".in").c_str(),"r",stdin);
		freopen((name+".out").c_str(),"w",stdout);
#endif
#endif
	}
#ifdef OI
	char getchar() {
		static const int IN=1e5;
		static char in[IN],*ip=in,*ie=in;
		return ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie)?EOF:*ip++;
	}
#else
	Istream &operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
#endif
	template <class T>
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}

	Istream &operator >>(char &ch) {
		while(!isalnum(ch=getchar()) && !ispunct(ch));
		return *this;
	}

	Istream &operator >>(char *s) {
		while(!isalnum(*s=getchar()) && !ispunct(*s));
		while(isalnum(*++s=getchar()) || ispunct(*s));
		*s=0;return *this;
	}

	template <class T>
	operator T() {
		static T x;*this>>x;
		return x;
	}
}fin;

struct Ostream {
#ifdef OO
	char out[(int)1e5],*op;

	Ostream():op(out) {}
	~Ostream() {
		flush();
	}

	void flush() {
		fwrite(out,1,op-out,stdout);
	}

	void putchar(char const &x) {
		*op==EOF && (flush(),op=out,*op++);
		*op++=x;
	}
#else
	Ostream &operator <<(double x) {
		printf("%.10lf",x);
		return *this;
	}
#endif
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}

	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}

	Ostream &operator <<(const char *s) {
		while(*s)
			putchar(*s++);
		return *this;
	}
}fout;

template <class T> bool Enlarge(T &a,T const &b) {
	return a<b?a=b,1:0;
}

template <class T> bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11,XLOGN=18;

int st[XN][XLOGN],lg2[XN];
int Min(int l,int r) {
	int lg=lg2[r-l+1];
	return std::min(st[l][lg],st[r-(1<<lg)+1][lg]);
}
int main() {
	int n,m;fin>>n>>m;
	static int a[XN],first[XN],last[XN];
	lg2[0]=-1;
	for(int i=1;i<=n;++i) {
		fin>>a[i];
		if(!first[a[i]])
			first[a[i]]=i;
		last[a[i]]=i;
		lg2[i]=lg2[i>>1]+1;
		st[i][0]=a[i]==0?m+1:a[i];
	}
	for(int lg=1;lg<=lg2[n];++lg)
		for(int i=1;i<=n-(1<<lg)+1;++i)
			st[i][lg]=std::min(st[i][lg-1],st[i+(1<<(lg-1))][lg-1]);
	bool tak=1;
	for(int x=1;x<=m;++x)
		if(first[x] && Min(first[x],last[x])<x) {
			tak=0;
			break;
		}
	if(tak) {
		puts("YES");
		if(a[1]==0) {
			int p=1;while(p<=n && a[p]==0) ++p;
			if(p==n+1)
				a[p+1]=m;
			for(int i=p;i>=1;--i)
				a[i]=a[i+1];
		}
		for(int i=1;i<=n;++i) {
			if(!a[i])
				a[i]=a[i-1];
			fout<<a[i]<<(i==n?'\n':' ');
		}
	} else
		puts("NO");
	return 0;
}


#include <bits/stdc++.h>
//105G
struct Istream {
	Istream() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
		freopen("input","r",stdin);
#else
		std::string fileName(__FILE__),name=fileName.substr(0,fileName.find('.'));
		freopen((name+".in").c_str(),"r",stdin);
		freopen((name+".out").c_str(),"w",stdout);
#endif
#endif
	}
#ifdef OI
	char getchar() {
		static const int IN=1e5;
		static char in[IN],*ip=in,*ie=in;
		return ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie)?EOF:*ip++;
	}
#else
	Istream &operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
#endif
	template <class T>
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}

	Istream &operator >>(char &ch) {
		while(!isalnum(ch=getchar()) && !ispunct(ch));
		return *this;
	}

	Istream &operator >>(char *s) {
		while(!isalnum(*s=getchar()) && !ispunct(*s));
		while(isalnum(*++s=getchar()) || ispunct(*s));
		*s=0;return *this;
	}

	template <class T>
	operator T() {
		static T x;*this>>x;
		return x;
	}
}fin;

struct Ostream {
#ifdef OO
	char out[(int)1e5],*op;

	Ostream():op(out) {}
	~Ostream() {
		flush();
	}

	void flush() {
		fwrite(out,1,op-out,stdout);
	}

	void putchar(char const &x) {
		*op==EOF && (flush(),op=out,*op++);
		*op++=x;
	}
#else
	Ostream &operator <<(double x) {
		printf("%.10lf",x);
		return *this;
	}
#endif
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}

	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}

	Ostream &operator <<(const char *s) {
		while(*s)
			putchar(*s++);
		return *this;
	}
}fout;

template <class T> bool Enlarge(T &a,T const &b) {
	return a<b?a=b,1:0;
}

template <class T> bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11;

int main() {
	int n,m;fin>>n>>m;
	static int a[XN],last[XN];
	for(int i=1;i<=n;++i) {
		fin>>a[i];
		last[a[i]]=i;
	}
	bool tak=1;
	for(int i=1,j=1;i<=n;i=j+1) {
		while(j<n && (a[j+1]==a[i] || a[j+1]==0)) {
			++j;
			if(a[j]==0)
				a[j]=a[i];
		}
		if(j<last[a[i]]) {
			tak=0;
			break;
		}
	}
	if(a[1]==0)
		for(int i=1;i<=n;++i)
			a[i]=1;
	if(tak) {
		puts("YES");
		for(int i=1;i<=n;++i)
			fout<<a[i]<<(i==n?'\n':' ');
	} else
		puts("NO");
	return 0;
}


#include <bits/stdc++.h>
//105G
struct Istream {
	Istream() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
		freopen("input","r",stdin);
#else
		std::string fileName(__FILE__),name=fileName.substr(0,fileName.find('.'));
		freopen((name+".in").c_str(),"r",stdin);
		freopen((name+".out").c_str(),"w",stdout);
#endif
#endif
	}
#ifdef OI
	char getchar() {
		static const int IN=1e5;
		static char in[IN],*ip=in,*ie=in;
		return ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie)?EOF:*ip++;
	}
#else
	Istream &operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
#endif
	template <class T>
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}

	Istream &operator >>(char &ch) {
		while(!isalnum(ch=getchar()) && !ispunct(ch));
		return *this;
	}

	Istream &operator >>(char *s) {
		while(!isalnum(*s=getchar()) && !ispunct(*s));
		while(isalnum(*++s=getchar()) || ispunct(*s));
		*s=0;return *this;
	}

	template <class T>
	operator T() {
		static T x;*this>>x;
		return x;
	}
}fin;

struct Ostream {
#ifdef OO
	char out[(int)1e5],*op;

	Ostream():op(out) {}
	~Ostream() {
		flush();
	}

	void flush() {
		fwrite(out,1,op-out,stdout);
	}

	void putchar(char const &x) {
		*op==EOF && (flush(),op=out,*op++);
		*op++=x;
	}
#else
	Ostream &operator <<(double x) {
		printf("%.10lf",x);
		return *this;
	}
#endif
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}

	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}

	Ostream &operator <<(const char *s) {
		while(*s)
			putchar(*s++);
		return *this;
	}
}fout;

template <class T> bool Enlarge(T &a,T const &b) {
	return a<b?a=b,1:0;
}

template <class T> bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11,XLOGN=18;

int st[XN][XLOGN],lg2[XN];
int Min(int l,int r) {
	int lg=lg2[r-l+1];
	return std::min(st[l][lg],st[r-(1<<lg)+1][lg]);
}
int main() {
	int n,m;fin>>n>>m;
	static int a[XN],first[XN],last[XN];
	lg2[0]=-1;
	for(int i=1;i<=n;++i) {
		fin>>a[i];
		if(!first[a[i]])
			first[a[i]]=i;
		last[a[i]]=i;
		lg2[i]=lg2[i>>1]+1;
		st[i][0]=a[i]==0?m+1:a[i];
	}
	for(int lg=1;lg<=lg2[n];++lg)
		for(int i=1;i<=n-(1<<lg)+1;++i)
			st[i][lg]=std::min(st[i][lg-1],st[i+(1<<(lg-1))][lg-1]);
	bool tak=1;
	for(int x=1;x<=m;++x)
		if(first[x] && Min(first[x],last[x])<x) {
			tak=0;
			break;
		}
	if(!first[m]) {
		if(first[0])
			a[first[0]]=m;
		else
			tak=0;
	}
	if(tak) {
		if(a[1]==0) {
			int p=1;
			while(a[p]==0) ++p;//此时必须有一个m了
			for(int i=p-1;i>=1;--i)
				a[i]=a[i+1];
		}
		puts("YES");
		for(int i=1;i<=n;++i) {
			if(!a[i])
				a[i]=a[i-1];
			fout<<a[i]<<(i==n?'\n':' ');
		}
	} else
		puts("NO");
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace  std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
typedef long double ld;
#define met(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
inline ll mul(ll x, ll y, ll mod) {ll res = (x * y - (ll)(ld)(x / mod * y + 1e-8) * mod); return res < 0 ? res + mod : res;}
const double PI = acos(-1.0);
const int mod = 1e9+7;
ll qPow(ll base, ll n) {ll res = 1; while(n) {if(n & 1) res = (res * base); base = (base * base); n >>= 1;} return res;}

int a[maxn];
int vis[maxn];
stack <int> s;

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    int fg=0, hq=-1;
    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        if(a[i]!=0) fg=1;
        if(a[i]==q) hq=q;
    }
    if(!fg) {
        puts("YES");
        for(int i=1;i<=n;i++) printf("%d ", q);
        return 0;
    }
    for(int i=1;i<=n;i++) {
        if(vis[a[i]]==1) fg=0;
        if(a[i]==0) {
            if(!vis[q]&&hq==-1) a[i]=q, hq=q;
            else {
                if(i-1<1) a[i]=a[i+1];
                else a[i]=a[i-1];
            }
        }
        while(!s.empty()&&s.top()>a[i]) {
            vis[s.top()]=1;
            s.pop();
        }
        s.push(a[i]);
    }
    for(int i=1;i<=n;i++) {
        if(a[i]!=0) {
            for(int j=i-1;j>=1;j--) a[j]=a[i];
            break;
        }
    }
    if(!fg||hq==-1) return 0*puts("NO");
    puts("YES");
    for(int i=1;i<=n;i++) printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace  std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
typedef long double ld;
#define met(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
inline ll mul(ll x, ll y, ll mod) {ll res = (x * y - (ll)(ld)(x / mod * y + 1e-8) * mod); return res < 0 ? res + mod : res;}
const double PI = acos(-1.0);
const int mod = 1e9+7;
ll qPow(ll base, ll n) {ll res = 1; while(n) {if(n & 1) res = (res * base); base = (base * base); n >>= 1;} return res;}

int a[maxn];
int vis[maxn];
stack <int> s;

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    int fg=0, hq=-1;
    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        if(a[i]!=0) fg=1;
        if(a[i]==q) hq=q;
    }
    if(!fg) {
        puts("YES");
        for(int i=1;i<=n;i++) printf("%d ", q);
        return 0;
    }
    for(int i=1;i<=n;i++) {
        if(vis[a[i]]==1) fg=0;
        if(a[i]==0) {
            if(!vis[q]&&hq==-1) a[i]=q, hq=q;
            else {
                if(i-1<1) a[i]=a[i+1];
                else a[i]=a[i-1];
            }
        }
        while(!s.empty()&&s.top()>a[i]) {
            vis[s.top()]=1;
            s.pop();
        }
        s.push(a[i]);
    }
    if(!fg||hq==-1) return 0*puts("NO");
    puts("YES");
    for(int i=1;i<=n;i++) printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace  std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
typedef long double ld;
#define met(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
inline ll mul(ll x, ll y, ll mod) {ll res = (x * y - (ll)(ld)(x / mod * y + 1e-8) * mod); return res < 0 ? res + mod : res;}
const double PI = acos(-1.0);
const int mod = 1e9+7;
ll qPow(ll base, ll n) {ll res = 1; while(n) {if(n & 1) res = (res * base); base = (base * base); n >>= 1;} return res;}

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    int a[maxn], vis[maxn], zero=-1;
    memset(vis, 0, sizeof(vis));
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    int fg=1, tp=-1, mx=-1;
    for(int i=1;i<=n;i++) {
        if(tp==-1&&a[i]==0) continue;
        if(a[i]!=0) mx=max(mx, a[i]);
        else zero=i;
        if(tp==-1) {
            tp=a[i];
            vis[tp]=1;
            continue;
        }
        if(tp==a[i]) continue;
        if(vis[a[i]]) {
            if(a[i]==0) a[i]=tp;
            else fg=0;
        }
        else {
            if(a[i]==0) a[i]=tp;
            else {
                tp=a[i];
                vis[tp]=1;
            }
        }
    }
    if(!fg||(mx<q&&mx!=-1)) {
        if(zero!=-1) {
            puts("YES");
            a[zero]=q;
            for(int i=1;i<=n;i++) printf("%d ", a[i]);
        }
        else puts("NO");
        return 0;
    }
    puts("YES");
    if(tp==-1) for(int i=1;i<=n;i++) printf("%d ", q);
    else for(int i=1;i<=n;i++) printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace  std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
typedef long double ld;
#define met(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
inline ll mul(ll x, ll y, ll mod) {ll res = (x * y - (ll)(ld)(x / mod * y + 1e-8) * mod); return res < 0 ? res + mod : res;}
const double PI = acos(-1.0);
const int mod = 1e9+7;
ll qPow(ll base, ll n) {ll res = 1; while(n) {if(n & 1) res = (res * base); base = (base * base); n >>= 1;} return res;}

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    int a[maxn], vis[maxn], zero=-1;
    memset(vis, 0, sizeof(vis));
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    int fg=1, tp=-1, mx=-1;
    for(int i=1;i<=n;i++) {
        if(tp==-1&&a[i]==0) continue;
        if(a[i]!=0) mx=max(mx, a[i]);
        else zero=i;
        if(tp==-1) {
            tp=a[i];
            vis[tp]=1;
            continue;
        }
        if(tp==a[i]) continue;
        if(vis[a[i]]&&a[i]>tp) {
            if(a[i]==0) a[i]=tp;
            else fg=0;
        }
        else {
            if(a[i]==0) a[i]=tp;
            else {
                tp=a[i];
                vis[tp]=1;
            }
        }
    }
//    for(int i=1;i<=n;i++) printf("%d ", a[i]);
    if(!fg||(mx<q&&mx!=-1)) {
        if(zero!=-1) {
            puts("YES");
            a[zero]=q;
            for(int i=1;i<=n;i++) printf("%d ", a[i]);
        }
        else puts("NO");
        return 0;
    }
    puts("YES");
    if(tp==-1) for(int i=1;i<=n;i++) printf("%d ", q);
    else for(int i=1;i<=n;i++) printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace  std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
typedef long double ld;
#define met(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
inline ll mul(ll x, ll y, ll mod) {ll res = (x * y - (ll)(ld)(x / mod * y + 1e-8) * mod); return res < 0 ? res + mod : res;}
const double PI = acos(-1.0);
const int mod = 1e9+7;
ll qPow(ll base, ll n) {ll res = 1; while(n) {if(n & 1) res = (res * base); base = (base * base); n >>= 1;} return res;}

int a[maxn];
int vis[maxn];
stack <int> s;

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    int fg=0, hq=-1;
    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        if(a[i]!=0) fg=1;
        if(a[i]==q) hq=q;
    }
    if(!fg) {
        puts("YES");
        for(int i=1;i<=n;i++) printf("%d ", q);
        return 0;
    }
    for(int i=1;i<=n;i++) {
        if(vis[a[i]]==1) fg=0;
        if(a[i]==0) {
            if(!vis[q]&&hq==-1) a[i]=q, hq=q;
            else a[i]=a[i-1];
        }
        while(!s.empty()&&s.top()>a[i]) {
            vis[s.top()]=1;
            s.pop();
        }
        s.push(a[i]);
    }
    if(!fg||hq==-1) return 0*puts("NO");
    puts("YES");
    for(int i=1;i<=n;i++) printf("%d ", a[i]);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define eps 1e-5
#define MAXN 200005
#define MAXM 11111
#define INF 1000000000
#define lch(x) x<<1
#define rch(x) x<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int mi[MAXN][17],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);if(w[i]==0)w[i]=q+1;}
    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        if(w[t]!=q+1)
        ans[i]=w[t];
        else ans[i]=1;
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
int a[500010];
int n,q;
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=2;i<n;++i)
	    if(a[i]&&a[i-1]>a[i]&&a[i+1]>a[i])
	        {puts("NO");return 0;}
	bool flg=0;
	for(int i=1;i<=n;++i)if(a[i]==q)flg=1;
	int mx=0;
	for(int i=1;i<=n;++i){
	    if(!flg&&mx!=q&&a[i]==0)a[i]=q;
	    if(a[i]==0)a[i]=a[i-1];
	    mx=std::max(mx,a[i]);
	}
	for(int i=n;i;--i)if(a[i]==0)a[i]=a[i+1];
	if(mx<q){puts("NO");return 0;}
	else puts("YES");
	for(int i=1;i<=n;++i)printf("%d ",a[i]);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#define MAXN 200005

using namespace std;
int mi[MAXN][33],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);}
    if(n==1 && w[1]==0)
    {
        printf("YES\n%d",q);
        return 0;
    }
    int flag1=0,flag2=0;
    for(int i=1; i<= n;i++)
    {
        if(w[i]==q)flag1=1;
        else if(w[i]==0)flag2=1;
        if(flag1 && flag2)break;
    }
    int flag3=1;
    if(!flag1 && flag2){
        for(int i=2;i<=n;i++)
        {
            if(flag3 &&w[i]==0)
            {
                w[i]=q;
                flag3=0;
            }
            else if( flag3==0 && w[i]==0)
            {
                w[i]=w[i-1];
            }
        }
        if(w[1]==0)w[1]=1;
    }
    else if(flag1 && flag2){
        if(w[1]==0)w[1]=1;
        for(int i=2;i<=n;i++)
        {
            if(w[i]==0)w[i]=w[i-1];
        }

    }
    else if(!flag1 && !flag2)
    {
        printf("NO");
        return 0;
    }

    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        ans[i]=w[t];
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define eps 1e-5
#define MAXN 200005
#define MAXM 11111
#define INF 1000000000
#define lch(x) x<<1
#define rch(x) x<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int mi[MAXN][17],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);}

    int flag1=0,flag2=0;
    for(int i=1; i<= n;i++)
    {
        if(w[i]==q)flag1=1;
        else if(w[i]==0)flag2=1;
        if(flag1 && flag2)break;
    }
    int flag3=1;
    if(!flag1 && flag2){
        for(int i=2;i<=n;i++)
        {
            if(flag3 &&w[i]==0)
            {
                w[i]=q;
                flag3=0;
            }
            else if( flag3==0 && w[i]==0)
            {
                w[i]=w[i-1];
            }
        }
        if(w[1]==0)w[1]=1;
    }
    else if(flag1 && flag2){
        if(w[1]==0)w[1]=1;
        for(int i=2;i<=n;i++)
        {
            if(w[i]==0)w[i]=w[i-1];
        }

    }
    else if(!flag1 && !flag2)
    {
        printf("NO");
        return 0;
    }

    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        ans[i]=w[t];
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define eps 1e-5
#define MAXN 200005
#define MAXM 11111
#define INF 1000000000
#define lch(x) x<<1
#define rch(x) x<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int mi[MAXN][17],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);if(w[i]==0)w[i]=q+1;}
    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        if(w[t]!=q+1)
        ans[i]=w[t];
        else ans[i]=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#define MAXN 200005

using namespace std;
int mi[MAXN][33],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);}

    int flag1=0,flag2=0;
    for(int i=1; i<= n;i++)
    {
        if(w[i]==q)flag1=1;
        else if(w[i]==0)flag2=1;
        if(flag1 && flag2)break;
    }
    int flag3=1;
    if(!flag1 && flag2){
        for(int i=2;i<=n;i++)
        {
            if(flag3 &&w[i]==0)
            {
                w[i]=q;
                flag3=0;
            }
            else if( flag3==0 && w[i]==0)
            {
                w[i]=w[i-1];
            }
        }
        if(w[1]==0)w[1]=1;
    }
    else if(flag1 && flag2){
        if(w[1]==0)w[1]=1;
        for(int i=2;i<=n;i++)
        {
            if(w[i]==0)w[i]=w[i-1];
        }

    }
    else if(!flag1 && !flag2)
    {
        printf("NO");
        return 0;
    }

    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        ans[i]=w[t];
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define eps 1e-5
#define MAXN 200005
#define MAXM 11111
#define INF 1000000000
#define lch(x) x<<1
#define rch(x) x<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int mi[MAXN][17],w[MAXN];
int n, q;
int flag[MAXN];
int pre[MAXN],bac[MAXN];
int ans[MAXN];
void rmqinit()
{
    for(int i = 1; i <= n; i++) mi[i][0] = i;
    int m = (int)(log(n * 1.0) / log(2.0));
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            mi[j][i] = mi[j][i - 1];
            if(j + (1 << (i - 1)) <= n)
            {
                if(w[mi[j][i]] > w[mi[j + (1 << (i - 1))][i - 1]]) mi[j][i] = mi[j + (1 << (i - 1))][i - 1];
            }
        }
}
int rmqmin(int l,int r)
{
    int m = (int)(log((r - l + 1) * 1.0) / log(2.0));
    if(w[mi[l][m]] > w[mi[r - (1 << m) + 1][m]]) return mi[r - (1 << m) + 1][m];
    else return mi[l][m];
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) {scanf("%d", &w[i]);if(w[i]==0)w[i]=q+1;}
    rmqinit();
   // for(int i=1;i<=n;i++)printf("%d",w[i]);putchar('\n');
    for(int i=1;i<=n;i++)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            pre[w[i]]=i;
        }
    }
    memset(flag,0,sizeof(flag));
    for(int i=n;i>0;i--)
    {
        if(!flag[w[i]])
        {
            flag[w[i]]=1;
            bac[w[i]]=i;
        }
    }
    int _flag;
    for(int i=1;i<=n;i++)
    {
        int t=rmqmin(pre[w[i]],bac[w[i]]);
      //  cout <<pre[w[i]]<<"***"<<bac[w[i]]<<endl;
      //  cout << w[t]<<endl;
        if(w[t]<w[i])
        {
            printf("NO");
            return 0;
        }
        if(w[t]!=q+1)
        ans[i]=w[t];
        else ans[i]=q;
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
    {
        if(i!=1)putchar(' ');
        printf("%d",ans[i]);
    }
    return 0;
}


#include<cstring>
#include<algorithm>
#include<cstdio>
#define lson nd<<1
#define rson nd<<1|1
#define rd read()
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
using namespace std;

const int N = 3e5, inf = ~0U >> 2;

int MIN[N << 2], a[N], L[N], R[N], lazy[N << 2], q, n, pos;
int Mok[N << 2];

int read() {
	int X = 0, p = 1; char c = getchar();
	for(; c > '9' || c < '0'; c = getchar()) if( c == '-') p = -1;
	for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
	return X * p;
}

void update(int nd) {
	MIN[nd] = min(MIN[lson], MIN[rson]);
}

void pushdown(int nd) {
	if(lazy[nd]) {
		Mok[lson] = lazy[nd];
		Mok[rson] = lazy[nd];
		lazy[lson] = lazy[rson] = lazy[nd];
		lazy[nd] = 0;
	}
}

void build(int l, int r, int nd) {
	if(l == r) {
		MIN[nd] = a[l] == 0 ? inf : a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(l, mid, lson);
	build(mid + 1, r, rson);
	update(nd);
}

int query(int Li, int Ri, int l, int r, int nd) {
	if(Li <= l && r <= Ri) return MIN[nd];
	int mid = (l + r) >> 1, re = inf;
	if(Li <= mid) re = min(re, query(Li, Ri, l, mid, lson));
	if(mid < Ri) re = min(re, query(Li, Ri, mid + 1, r, rson));
	return re;
}

int query_pt(int p, int l, int r, int nd) {
	if(l == r) return Mok[nd];
	int mid = (l + r) >> 1;
	if(p <= mid) return query_pt(p, l, mid, lson);
	else return query_pt(p, mid + 1, r, rson);
}

void change(int Li, int Ri, int c, int l, int r, int nd) {
	if(Li <= l && r <= Ri) {
		lazy[nd] = c;
		Mok[nd] = c;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(Li <= mid) change(Li, Ri, c, l, mid, lson);
	if(mid < Ri) change(Li, Ri, c, mid + 1, r, rson);
	update(nd);
}

int main()
{
	n = rd; q = rd;
	for(int i = 1; i <= n; ++i) {
		a[i] = rd;
		if(!a[i]) pos = i;
		if(!L[a[i]]) L[a[i]] = i;
		R[a[i]] = i;
	}
	if(!L[q] && !pos) return printf("NO\n"), 0;
	build(1, n, 1);
	for(int i = 1; i <= q; ++i) {
		if(!L[i]) continue;
		int minv = query(L[i], R[i], 1, n, 1);
		if(minv < i) return printf("NO\n"), 0;
		change(L[i], R[i], i, 1, n, 1);
	}
	for(int i = 1; i <= n; ++i) if(!a[i]) {
		a[i] = query_pt(i, 1, n, 1);
		if(i == pos) a[i] = q;
		else if(!a[i]) a[i] = 1;
	}
	printf("YES\n");
	for(int i = 1; i <= n; ++i) printf("%d ", a[i]);
	putchar('\n');
}


#include<cstring>
#include<algorithm>
#include<cstdio>
#define lson nd<<1
#define rson nd<<1|1
#define rd read()
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
using namespace std;

const int N = 3e5, inf = ~0U >> 2;

int MIN[N << 2], a[N], L[N], R[N], lazy[N << 2], q, n;
int Mok[N << 2];

int read() {
	int X = 0, p = 1; char c = getchar();
	for(; c > '9' || c < '0'; c = getchar()) if( c == '-') p = -1;
	for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
	return X * p;
}

void update(int nd) {
	MIN[nd] = min(MIN[lson], MIN[rson]);
}

void pushdown(int nd) {
	if(lazy[nd]) {
		Mok[lson] = lazy[nd];
		Mok[rson] = lazy[nd];
		lazy[lson] = lazy[rson] = lazy[nd];
		lazy[nd] = 0;
	}
}

void build(int l, int r, int nd) {
	if(l == r) {
		MIN[nd] = a[l] == 0 ? inf : a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(l, mid, lson);
	build(mid + 1, r, rson);
	update(nd);
}

int query(int Li, int Ri, int l, int r, int nd) {
	if(Li <= l && r <= Ri) return MIN[nd];
	int mid = (l + r) >> 1, re = inf;
	if(Li <= mid) re = min(re, query(Li, Ri, l, mid, lson));
	if(mid < Ri) re = min(re, query(Li, Ri, mid + 1, r, rson));
	return re;
}

int query_pt(int p, int l, int r, int nd) {
	if(l == r) return Mok[nd];
	int mid = (l + r) >> 1;
	if(p <= mid) return query_pt(p, l, mid, lson);
	else return query_pt(p, mid + 1, r, rson);
}

void change(int Li, int Ri, int c, int l, int r, int nd) {
	if(Li <= l && r <= Ri) {
		lazy[nd] = c;
		Mok[nd] = c;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(Li <= mid) change(Li, Ri, c, l, mid, lson);
	if(mid < Ri) change(Li, Ri, c, mid + 1, r, rson);
	update(nd);
}

int main()
{
	n = rd; q = rd;
	for(int i = 1; i <= n; ++i) {
		a[i] = rd;
		if(!L[a[i]]) L[a[i]] = i;
		R[a[i]] = i;
	}
	build(1, n, 1);
	for(int i = 1; i <= q; ++i) {
		if(!L[i]) continue;
		int minv = query(L[i], R[i], 1, n, 1);
		if(minv < i) return printf("NO\n"), 0;
		change(L[i], R[i], i, 1, n, 1);
	}
	for(int i = 1; i <= n; ++i) if(!a[i]) {
		a[i] = query_pt(i, 1, n, 1);
		if(!a[i]) a[i] = 1;
	}
	printf("YES\n");
	for(int i = 1; i <= n; ++i) printf("%d ", a[i]);
	putchar('\n');
}


#include<cstring>
#include<algorithm>
#include<cstdio>
#define lson nd<<1
#define rson nd<<1|1
#define rd read()
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
using namespace std;

const int N = 3e5, inf = ~0U >> 2;

int MIN[N << 2], a[N], L[N], R[N], lazy[N << 2], q, n, pos;
int Mok[N << 2];

int read() {
	int X = 0, p = 1; char c = getchar();
	for(; c > '9' || c < '0'; c = getchar()) if( c == '-') p = -1;
	for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
	return X * p;
}

void update(int nd) {
	MIN[nd] = min(MIN[lson], MIN[rson]);
}

void pushdown(int nd) {
	if(lazy[nd]) {
		Mok[lson] = lazy[nd];
		Mok[rson] = lazy[nd];
		lazy[lson] = lazy[rson] = lazy[nd];
		lazy[nd] = 0;
	}
}

void build(int l, int r, int nd) {
	if(l == r) {
		MIN[nd] = a[l] == 0 ? inf : a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(l, mid, lson);
	build(mid + 1, r, rson);
	update(nd);
}

int query(int Li, int Ri, int l, int r, int nd) {
	if(Li <= l && r <= Ri) return MIN[nd];
	int mid = (l + r) >> 1, re = inf;
	if(Li <= mid) re = min(re, query(Li, Ri, l, mid, lson));
	if(mid < Ri) re = min(re, query(Li, Ri, mid + 1, r, rson));
	return re;
}

int query_pt(int p, int l, int r, int nd) {
	if(l == r) return Mok[nd];
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(p <= mid) return query_pt(p, l, mid, lson);
	else return query_pt(p, mid + 1, r, rson);
}

void change(int Li, int Ri, int c, int l, int r, int nd) {
	if(Li <= l && r <= Ri) {
		lazy[nd] = c;
		Mok[nd] = c;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(Li <= mid) change(Li, Ri, c, l, mid, lson);
	if(mid < Ri) change(Li, Ri, c, mid + 1, r, rson);
	update(nd);
}

int main()
{
	n = rd; q = rd;
	for(int i = 1; i <= n; ++i) {
		a[i] = rd;
		if(!a[i]) pos = i;
		if(!L[a[i]]) L[a[i]] = i;
		R[a[i]] = i;
	}
	if(!L[q] && !pos) return printf("NO\n"), 0;
	build(1, n, 1);
	for(int i = 1; i <= q; ++i) {
		if(!L[i]) continue;
		int minv = query(L[i], R[i], 1, n, 1);
		if(minv < i) return printf("NO\n"), 0;
		change(L[i], R[i], i, 1, n, 1);
	}
	for(int i = 1; i <= n; ++i) if(!a[i]) {
		a[i] = query_pt(i, 1, n, 1);
		if(i == pos && !L[q]) a[i] = q;
		else if(!a[i]) a[i] = 1;
	}
	printf("YES\n");
	for(int i = 1; i <= n; ++i) printf("%d ", a[i]);
	putchar('\n');
}


#include<cstring>
#include<algorithm>
#include<cstdio>
#define lson nd<<1
#define rson nd<<1|1
#define rd read()
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
using namespace std;

const int N = 3e5, inf = ~0U >> 2;

int MIN[N << 2], a[N], L[N], R[N], lazy[N << 2], q, n, pos;
int Mok[N << 2];

int read() {
	int X = 0, p = 1; char c = getchar();
	for(; c > '9' || c < '0'; c = getchar()) if( c == '-') p = -1;
	for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
	return X * p;
}

void update(int nd) {
	MIN[nd] = min(MIN[lson], MIN[rson]);
}

void pushdown(int nd) {
	if(lazy[nd]) {
		Mok[lson] = lazy[nd];
		Mok[rson] = lazy[nd];
		lazy[lson] = lazy[rson] = lazy[nd];
		lazy[nd] = 0;
	}
}

void build(int l, int r, int nd) {
	if(l == r) {
		MIN[nd] = a[l] == 0 ? inf : a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(l, mid, lson);
	build(mid + 1, r, rson);
	update(nd);
}

int query(int Li, int Ri, int l, int r, int nd) {
	if(Li <= l && r <= Ri) return MIN[nd];
	int mid = (l + r) >> 1, re = inf;
	if(Li <= mid) re = min(re, query(Li, Ri, l, mid, lson));
	if(mid < Ri) re = min(re, query(Li, Ri, mid + 1, r, rson));
	return re;
}

int query_pt(int p, int l, int r, int nd) {
	if(l == r) return Mok[nd];
	int mid = (l + r) >> 1;
	if(p <= mid) return query_pt(p, l, mid, lson);
	else return query_pt(p, mid + 1, r, rson);
}

void change(int Li, int Ri, int c, int l, int r, int nd) {
	if(Li <= l && r <= Ri) {
		lazy[nd] = c;
		Mok[nd] = c;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(Li <= mid) change(Li, Ri, c, l, mid, lson);
	if(mid < Ri) change(Li, Ri, c, mid + 1, r, rson);
	update(nd);
}

int main()
{
	n = rd; q = rd;
	for(int i = 1; i <= n; ++i) {
		a[i] = rd;
		if(!a[i]) pos = i;
		if(!L[a[i]]) L[a[i]] = i;
		R[a[i]] = i;
	}
	if(!L[q] && !pos) return printf("NO\n");
	build(1, n, 1);
	for(int i = 1; i <= q; ++i) {
		if(!L[i]) continue;
		int minv = query(L[i], R[i], 1, n, 1);
		if(minv < i) return printf("NO\n"), 0;
		change(L[i], R[i], i, 1, n, 1);
	}
	for(int i = 1; i <= n; ++i) if(!a[i]) {
		a[i] = query_pt(i, 1, n, 1);
		if(!a[i] && !L[q]) a[i] = q, L[q] = i;
		else if(!a[i]) a[i] = 1;
	}
	printf("YES\n");
	for(int i = 1; i <= n; ++i) printf("%d ", a[i]);
	putchar('\n');
}


#include<cstring>
#include<algorithm>
#include<cstdio>
#define lson nd<<1
#define rson nd<<1|1
#define rd read()
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
using namespace std;

const int N = 3e5, inf = ~0U >> 2;

int MIN[N << 2], a[N], L[N], R[N], lazy[N << 2], q, n, pos;
int Mok[N << 2];

int read() {
	int X = 0, p = 1; char c = getchar();
	for(; c > '9' || c < '0'; c = getchar()) if( c == '-') p = -1;
	for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
	return X * p;
}

void update(int nd) {
	MIN[nd] = min(MIN[lson], MIN[rson]);
}

void pushdown(int nd) {
	if(lazy[nd]) {
		Mok[lson] = lazy[nd];
		Mok[rson] = lazy[nd];
		lazy[lson] = lazy[rson] = lazy[nd];
		lazy[nd] = 0;
	}
}

void build(int l, int r, int nd) {
	if(l == r) {
		MIN[nd] = a[l] == 0 ? inf : a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(l, mid, lson);
	build(mid + 1, r, rson);
	update(nd);
}

int query(int Li, int Ri, int l, int r, int nd) {
	if(Li <= l && r <= Ri) return MIN[nd];
	int mid = (l + r) >> 1, re = inf;
	if(Li <= mid) re = min(re, query(Li, Ri, l, mid, lson));
	if(mid < Ri) re = min(re, query(Li, Ri, mid + 1, r, rson));
	return re;
}

int query_pt(int p, int l, int r, int nd) {
	if(l == r) return Mok[nd];
	int mid = (l + r) >> 1;
	if(p <= mid) return query_pt(p, l, mid, lson);
	else return query_pt(p, mid + 1, r, rson);
}

void change(int Li, int Ri, int c, int l, int r, int nd) {
	if(Li <= l && r <= Ri) {
		lazy[nd] = c;
		Mok[nd] = c;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(nd);
	if(Li <= mid) change(Li, Ri, c, l, mid, lson);
	if(mid < Ri) change(Li, Ri, c, mid + 1, r, rson);
	update(nd);
}

int main()
{
	n = rd; q = rd;
	for(int i = 1; i <= n; ++i) {
		a[i] = rd;
		if(!a[i]) pos = i;
		if(!L[a[i]]) L[a[i]] = i;
		R[a[i]] = i;
	}
	if(!L[q] && !pos) return printf("NO\n"), 0;
	build(1, n, 1);
	for(int i = 1; i <= q; ++i) {
		if(!L[i]) continue;
		int minv = query(L[i], R[i], 1, n, 1);
		if(minv < i) return printf("NO\n"), 0;
		change(L[i], R[i], i, 1, n, 1);
	}
	for(int i = 1; i <= n; ++i) if(!a[i]) {
		a[i] = query_pt(i, 1, n, 1);
		if(i == pos && !L[q]) a[i] = q;
		else if(!a[i]) a[i] = 1;
	}
	printf("YES\n");
	for(int i = 1; i <= n; ++i) printf("%d ", a[i]);
	putchar('\n');
}


#include<bits/stdc++.h>
using namespace std;
int pos[200005];
int n,q;
const int INF=2000005;
int a[200005],ans[200005<<2];

void PushUp(int rt)
{
    ans[rt]=min(ans[rt<<1],ans[rt<<1|1]);
}

void Build(int l,int r,int rt)
{
    if (l==r)
    {
        ans[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    Build(l,mid,rt<<1);
    Build(mid+1,r,rt<<1|1);
    PushUp(rt);
}

long long Query(int L,int R,int l,int r,int rt)
{
    if (L<=l&&r<=R)
        return ans[rt];
    int mid=(l+r)>>1;
    //PushDown(rt,mid-l+1,r-mid);
    long long ANS=100000000;
    if (L<=mid) ANS=min(ANS,Query(L,R,l,mid,rt<<1));
    if (R>mid) ANS=min(ANS,Query(L,R,mid+1,r,rt<<1|1));
    return ANS;
}

int main()
{
	cin>>n>>q;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]!=0)f=1;
		else a[i]=INF;
	}
	if(!f)
	{
		puts("YES");
		for(int i=1;i<=n;i++)cout<<1<<" ";
		cout<<endl;
		return 0;
	}
	Build(1,n,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)continue;
		if(pos[a[i]]==0)pos[a[i]]=i;
		else
		{
			long long res=Query(pos[a[i]],i,1,n,1);
			//cout<<pos[a[i]]<<" "<<i<<" "<<res<<endl;
			if(res<a[i])
			{
				puts("NO");
				return 0;
			}
		}
	}
	if(pos[q]==0)
	{
		puts("NO");
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)cout<<1<<" ";
		else cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int pos[200005];
int n,q;
const int INF=2000005;
int a[200005],ans[200005<<2];

void PushUp(int rt)
{
    ans[rt]=min(ans[rt<<1],ans[rt<<1|1]);
}

void Build(int l,int r,int rt)
{
    if (l==r)
    {
        ans[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    Build(l,mid,rt<<1);
    Build(mid+1,r,rt<<1|1);
    PushUp(rt);
}

long long Query(int L,int R,int l,int r,int rt)
{
    if (L<=l&&r<=R)
        return ans[rt];
    int mid=(l+r)>>1;
    //PushDown(rt,mid-l+1,r-mid);
    long long ANS=100000000;
    if (L<=mid) ANS=min(ANS,Query(L,R,l,mid,rt<<1));
    if (R>mid) ANS=min(ANS,Query(L,R,mid+1,r,rt<<1|1));
    return ANS;
}

int main()
{
	cin>>n>>q;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]!=0)f=1;
		else a[i]=INF;
	}
	if(!f)
	{
		puts("YES");
		for(int i=1;i<=n;i++)cout<<1<<" ";
		cout<<endl;
		return 0;
	}
	Build(1,n,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)continue;
		if(pos[a[i]]==0)pos[a[i]]=i;
		else
		{
			long long res=Query(pos[a[i]],i,1,n,1);
			//cout<<pos[a[i]]<<" "<<i<<" "<<res<<endl;
			if(res<a[i])
			{

				puts("NO");
				return 0;
			}
		}
	}
	if(pos[q]==0)
	{
		puts("NO");
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)cout<<1<<" ";
		else cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
//leo
using namespace std;
int pos[200005];
int n,q;
const int INF=2000005;
int a[200005],ans[200005<<2];

void PushUp(int rt)
{
    ans[rt]=min(ans[rt<<1],ans[rt<<1|1]);
}

void Build(int l,int r,int rt)
{
    if (l==r)
    {
        ans[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    Build(l,mid,rt<<1);
    Build(mid+1,r,rt<<1|1);
    PushUp(rt);
}

long long Query(int L,int R,int l,int r,int rt)
{
    if (L<=l&&r<=R)
        return ans[rt];
    int mid=(l+r)>>1;
    //PushDown(rt,mid-l+1,r-mid);
    long long ANS=100000000;
    if (L<=mid) ANS=min(ANS,Query(L,R,l,mid,rt<<1));
    if (R>mid) ANS=min(ANS,Query(L,R,mid+1,r,rt<<1|1));
    return ANS;
}

int main()
{
	cin>>n>>q;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]!=0)f=1;
		else a[i]=INF;
	}
	if(!f)
	{
		puts("YES");
		for(int i=1;i<=n;i++)cout<<1<<" ";
		cout<<endl;
		return 0;
	}
	Build(1,n,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)continue;
		if(pos[a[i]]==0)pos[a[i]]=i;
		else
		{
			long long res=Query(pos[a[i]],i,1,n,1);
			//cout<<pos[a[i]]<<" "<<i<<" "<<res<<endl;
			if(res<a[i])
			{

				puts("NO");
				return 0;
			}
		}
	}
	if(pos[q]==0)
	{
		puts("NO");
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)cout<<1<<" ";
		else cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int pos[200005];
int n,q;
const int INF=2000005;
int a[200005],ans[200005<<2];

void PushUp(int rt)
{
    ans[rt]=min(ans[rt<<1],ans[rt<<1|1]);
}

void Build(int l,int r,int rt)
{
    if (l==r)
    {
        ans[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    Build(l,mid,rt<<1);
    Build(mid+1,r,rt<<1|1);
    PushUp(rt);
}

long long Query(int L,int R,int l,int r,int rt)
{
    if (L<=l&&r<=R)
        return ans[rt];
    int mid=(l+r)>>1;
    //PushDown(rt,mid-l+1,r-mid);
    long long ANS=100000000;
    if (L<=mid) ANS=min(ANS,Query(L,R,l,mid,rt<<1));
    if (R>mid) ANS=min(ANS,Query(L,R,mid+1,r,rt<<1|1));
    return ANS;
}

int main()
{
	cin>>n>>q;
	bool f=0;
	int tmppos=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			f=1;
			a[i]=INF;
			tmppos=i;
		}
	}
	Build(1,n,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)continue;
		if(pos[a[i]]==0)pos[a[i]]=i;
		else
		{
			long long res=Query(pos[a[i]],i,1,n,1);
			//cout<<pos[a[i]]<<" "<<i<<" "<<res<<endl;
			if(res<a[i])
			{
				puts("NO");
				return 0;
			}
		}
	}
	if(pos[q]==0 && f==0)
	{
		puts("NO");
		return 0;
	}
	cout<<"YES"<<endl;
	int tmp=1;
	for(int i=n;i>=1;i--)
	{
		if(i==tmppos && pos[q]==0)a[i]=q;
		else if(a[i]==INF)
		{
			a[i]=tmp;
		}
		else
		{
			tmp=a[i];
		}
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int pos[200005];
int n,q;
const int INF=2000005;
int a[200005],ans[200005<<2];

void PushUp(int rt)
{
    ans[rt]=min(ans[rt<<1],ans[rt<<1|1]);
}

void Build(int l,int r,int rt)
{
    if (l==r)
    {
        ans[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    Build(l,mid,rt<<1);
    Build(mid+1,r,rt<<1|1);
    PushUp(rt);
}

long long Query(int L,int R,int l,int r,int rt)
{
    if (L<=l&&r<=R)
        return ans[rt];
    int mid=(l+r)>>1;
    //PushDown(rt,mid-l+1,r-mid);
    long long ANS=100000000;
    if (L<=mid) ANS=min(ANS,Query(L,R,l,mid,rt<<1));
    if (R>mid) ANS=min(ANS,Query(L,R,mid+1,r,rt<<1|1));
    return ANS;
}

int main()
{
	cin>>n>>q;
	bool f=0;
	int tmppos=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			f=1;
			a[i]=INF;
			tmppos=i;
		}
	}
	Build(1,n,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==INF)continue;
		if(pos[a[i]]==0)pos[a[i]]=i;
		else
		{
			long long res=Query(pos[a[i]],i,1,n,1);
			//cout<<pos[a[i]]<<" "<<i<<" "<<res<<endl;
			if(res<a[i])
			{
				puts("NO");
				return 0;
			}
		}
	}
	if(pos[q]==0 && f==0)
	{
		puts("NO");
		return 0;
	}
	cout<<"YES"<<endl;
	int tmp=q;
	for(int i=n;i>=1;i--)
	{
		if(i==tmppos)cout<<q<<" ";
		else if(a[i]==INF)
		{
			cout<<tmp<<" ";
		}
		else
		{
			tmp=a[i];
			cout<<a[i]<<" ";
		}
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mp[200010];
ll ans[200010];
priority_queue<ll> f;
vector<pair<ll,ll> > num(200010);
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    mp[0]=1;
    ll ma=0;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        scanf("%lld",&x);
        if(x==0) mp[i]=mp[i-1];
        else mp[i]=x;
        if(num[mp[i]].first==0){
            num[mp[i]].first=i;
        }
        if(ma<x) ma=x;
        num[mp[i]].second=i;
    }
    if(ma!=m){
        printf("NO");
        return 0;
    }
    for(ll i=1;i<=n;i++)
    {
        if(f.empty())
        {
            if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
        }
        else
        {
            ll t;
            t=f.top();
            if(num[t].second==i) f.pop();
            else if(t>mp[i])
            {
                printf("NO");
                return 0;
            }
            else if(t<mp[i])
            {
                if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
            }
        }
    }

    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);

    /*
    ll f1=1;
    ll l1=n;
    ll t=0;
    f.push(mp[1]);
    f.push(mp[n]);
    while(f1<l1)
    {
        if(mp[f1]<mp[l1])
        {
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
        else if(mp[f1]>mp[l1]){
            if(mp[l1-1]<mp[l1]&&mp[l1-1]<t){
                printf("NO");
                return 0;
            }
            l1--;
        }
        else
        {
            t=mp[f1];
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
    }
    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);*/
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mp[200010];
ll ans[200010];
priority_queue<ll> f;
priority_queue<ll> l;
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    mp[0]=1;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        scanf("%lld",&x);
        if(x==0) mp[i]=mp[i-1];
        else mp[i]=x;
    }
    ll f1=1;
    ll l1=n;
    ll t=0;
    f.push(mp[1]);
    f.push(mp[n]);
    while(f1<l1)
    {
        if(mp[f1]<mp[l1])
        {
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
        else if(mp[f1]>mp[l1]){
            if(mp[l1-1]<mp[l1]&&mp[l1-1]<t){
                printf("NO");
                return 0;
            }
            l1--;
        }
        else
        {
            t=mp[f1];
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
    }
    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mp[200010];
ll ans[200010];
priority_queue<ll> f;
ll ze;
vector<pair<ll,ll> > num(200010);
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    mp[0]=1;
    ll ma=0;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        scanf("%lld",&x);
        if(x==0)
        {mp[i]=mp[i-1];
            ze=i;
        }
        else mp[i]=x;
        if(num[mp[i]].first==0){
            num[mp[i]].first=i;
        }
        if(ma<x) ma=x;
        num[mp[i]].second=i;
    }
    if(ma!=m&&ze==0){
        printf("NO");
        return 0;
    }
    else if(ma!=m){
        mp[ze]=m;
    }
    for(ll i=1;i<=n;i++)
    {
        if(f.empty())
        {
            if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
        }
        else
        {
            ll t;
            t=f.top();
            if(num[t].second==i) f.pop();
            else if(t>mp[i])
            {
                printf("NO");
                return 0;
            }
            else if(t<mp[i])
            {
                if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
            }
        }
    }

    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);

    /*
    ll f1=1;
    ll l1=n;
    ll t=0;
    f.push(mp[1]);
    f.push(mp[n]);
    while(f1<l1)
    {
        if(mp[f1]<mp[l1])
        {
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
        else if(mp[f1]>mp[l1]){
            if(mp[l1-1]<mp[l1]&&mp[l1-1]<t){
                printf("NO");
                return 0;
            }
            l1--;
        }
        else
        {
            t=mp[f1];
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
    }
    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);*/
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mp[200010];
ll ans[200010];
priority_queue<ll> f;
vector<pair<ll,ll> > num(200010);
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    mp[0]=1;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        scanf("%lld",&x);
        if(x==0) mp[i]=mp[i-1];
        else mp[i]=x;
        if(num[mp[i]].first==0){
            num[mp[i]].first=i;
        }
        num[mp[i]].second=i;
    }
    for(ll i=1;i<=n;i++)
    {
        if(f.empty())
        {
            if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
        }
        else
        {
            ll t;
            t=f.top();
            if(num[t].second==i) f.pop();
            else if(t>mp[i])
            {
                printf("NO");
                return 0;
            }
            else if(t<mp[i])
            {
                if(num[mp[i]].first!=num[mp[i]].second) f.push(mp[i]);
            }
        }
    }

    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);

    /*
    ll f1=1;
    ll l1=n;
    ll t=0;
    f.push(mp[1]);
    f.push(mp[n]);
    while(f1<l1)
    {
        if(mp[f1]<mp[l1])
        {
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
        else if(mp[f1]>mp[l1]){
            if(mp[l1-1]<mp[l1]&&mp[l1-1]<t){
                printf("NO");
                return 0;
            }
            l1--;
        }
        else
        {
            t=mp[f1];
            if(mp[f1+1]<mp[f1]&&mp[f1+1]<t){
                printf("NO");
                return 0;
            }
            f1++;
        }
    }
    printf("YES\n");
    for(ll i=1;i<=n;i++)
        printf("%lld ",mp[i]);*/
    return 0;
}


#include<bits/stdc++.h>
const int N = 2e6+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline void pushdown(int cur){
	if(cur>((2e5)*4)) return ;
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(cur>((2e5)*4)) return 0 ;
	if(l>r) return 0;
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(cur>((2e5)*4)) return ;
	if(L>R||l>r) return ;
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=q;i;--i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<bits/stdc++.h>
const int N = 1e5+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline pushdown(int cur){
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
inline int get(int cur,int l,int r,int x){
	if(l==r) return cur;
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return get(cur<<1,l,mid,x);
	else return get(cur<<1|1,mid+1,r,x);
}
inline int push(int cur,int l,int r){
	if(l==r) return 0;
	int mid=l+r>>1;
	pushdown(cur);
	push(cur<<1,l,mid);
	push(cur<<1|1,mid+1,r);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=q;i;--i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<bits/stdc++.h>
const int N = 1e7+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline void pushdown(int cur){
	if(cur>((1e5)*4)) return ;
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(cur>((1e5)*4)) return 0 ;
	if(l>r) return 0;
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(cur>((1e5)*4)) return ;
	if(L>R||l>r) return ;
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=q;i;--i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<bits/stdc++.h>
const int N = 1e5+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline pushdown(int cur){
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
inline int get(int cur,int l,int r,int x){
	if(l==r) return cur;
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return get(cur<<1,l,mid,x);
	else return get(cur<<1|1,mid+1,r,x);
}
inline int push(int cur,int l,int r){
	if(l==r) return 0;
	int mid=l+r>>1;
	pushdown(cur);
	push(cur<<1,l,mid);
	push(cur<<1|1,mid+1,r);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=1;i<=q;++i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<bits/stdc++.h>
const int N = 2e6+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline void pushdown(int cur){
	if(cur>((1e5)*4)) return ;
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(cur>((1e5)*4)) return 0 ;
	if(l>r) return 0;
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(cur>((1e5)*4)) return ;
	if(L>R||l>r) return ;
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=q;i;--i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<bits/stdc++.h>
const int N = 1e5+1e2;
int sum[N<<2],cov[N<<2];
int a[N],b[N],n,l[N],r[N],ans[N];
inline void pushdown(int cur){
	if(cur>((N-1e2)*4)) return ;
	if(cov[cur]!=-1){
		cov[cur<<1]=cov[cur<<1|1]=cov[cur];
		sum[cur<<1]=sum[cur<<1|1]=cov[cur];
		cov[cur]=-1;
	}
}
inline int ask(int cur,int l,int r,int x){
	if(cur>((N-1e2)*4)) return 0 ;
	if(l>r) return 0;
	if(l==r) return sum[cur];
	int mid=l+r>>1;
	pushdown(cur);
	if(x<=mid) return ask(cur<<1,l,mid,x);
	else return ask(cur<<1|1,mid+1,r,x);
}
inline void modify(int cur,int l,int r,int L,int R,int x){
	if(cur>((N-1e2)*4)) return ;
	if(L>R||l>r) return ;
	if(L<=l&&r<=R){
		cov[cur]=sum[cur]=x;
		return ;
	}
	int mid=l+r>>1;
	pushdown(cur);
	if(L<=mid) modify(cur<<1,l,mid,L,R,x);
	if(R>mid) modify(cur<<1|1,mid+1,r,L,R,x);
}
int sss=0;
int main(){
	int q;
	scanf("%d %d",&n,&q);
//	for(int i=1;i<=q;++i) l[i]=1,r[i]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!l[a[i]]) l[a[i]]=i;
		r[a[i]]=i;
		if(a[i]==0) sss=i;
	}
	for(int i=q;i;--i) if(!l[i]){
		if(sss)
			l[i]=sss,r[i]=sss;
		else
			{
				if(i!=q)
					l[i]=l[i+1],r[i]=r[i+1];
				else{
					printf("NO");
					return 0;
				}
			}
	}
	memset(cov,-1,sizeof(cov));
	l[1]=1,r[1]=n;
	for(int i=1;i<=q;++i){
		modify(1,1,n,l[i],r[i],i);
	}
	for(int i=1;i<=n;++i){
		ans[i]=ask(1,1,n,i);
		if(ans[i]!=a[i]&&a[i]!=0){
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=1;i<=n;++i){
		if(ans[i]==0)
			if(i!=1) ans[i]=ans[i-1];
			else ans[i]=ans[i+1];
		printf("%d ",ans[i]);
	}
}


#include<set>
#include<cstdio>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int maxn=200000+5;
std::set<int>S;
int point[2][maxn];
int seq[maxn];
int a[maxn];
bool Max;
int Zero;
int n,q;
inline int Read(){
	register int ret;
	register char r;
	while(r=getchar(),r<'0'||r>'9');ret=r-48;
	while(r=getchar(),r>='0'&&r<='9')ret=(ret<<3)+(ret<<1)+r-48;
	return ret;
}
int main(){
	n=Read(),q=Read();
	memset(point[0],0x3f,sizeof(point[0]));
	for(register int i=1;i<=n;i++){
		a[i]=Read(),
		point[0][a[i]]=min(point[0][a[i]],i);
		point[1][a[i]]=max(point[1][a[i]],i);
	}
//	printf("%d %d\n",point[0][10],point[1][10]);
	for(register int i=1;i<=n;i++){
		if(a[i]==q)Max=true;
		if(!a[i]){
			if(!S.size())S.insert(1);
			seq[i]=*--S.end();
			Zero=i;
		}
		else{
			if(i==point[0][a[i]]){
				if(S.size()&&
					*--S.end()>a[i])return puts("NO");
				S.insert(a[i]);
			}
			if(i==point[1][a[i]]){
				if(point[0][a[i]]<point[1][a[i]]&&
					seq[i-1]<a[i])return puts("NO");
				S.erase(a[i]);
			}
			seq[i]=a[i];
		}
	}
	if((!Max)&&(!Zero))return puts("NO");
	if(!Max)seq[Zero]=q;puts("YES");
	for(register int i=1;i<=n;i++)
		printf("%d ",seq[i]);
	return 0;
}


#pragma GCC optimize("O2")
#include<set>
#include<cstdio>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int maxn=200000+5;
std::set<int>S;
int point[2][maxn];
int seq[maxn];
int a[maxn];
bool Max;
int Zero;
int n,q;
inline int Read(){
	register int ret;
	register char r;
	while(r=getchar(),r<'0'||r>'9');ret=r-48;
	while(r=getchar(),r>='0'&&r<='9')ret=(ret<<3)+(ret<<1)+r-48;
	return ret;
}
int main(){
	n=Read(),q=Read();
	memset(point[0],0x3f,sizeof(point[0]));
	for(register int i=1;i<=n;i++){
		a[i]=Read(),
		point[0][a[i]]=min(point[0][a[i]],i);
		point[1][a[i]]=max(point[1][a[i]],i);
	}
	for(register int i=1;i<=n;i++){
		if(a[i]==q)Max=true;
		if(!a[i]){
			if(!S.size())S.insert(1);
			seq[i]=*--S.end();
			Zero=i;
		}
		else{
			if(i==point[0][a[i]]){
				if(S.size()&&
					*--S.end()>a[i])return puts("NO");
				S.insert(a[i]);
			}
			if(i==point[1][a[i]]){
				if(point[0][a[i]]<point[1][a[i]]&&
					seq[i-1]<a[i])return puts("NO");
				S.erase(a[i]);
			}
			seq[i]=a[i];
		}
	}
	if((!Max)&&(!Zero))return puts("NO");
	if(!Max)seq[Zero]=q;puts("YES");
	for(register int i=1;i<=n;i++)
		printf("%d ",seq[i]);
	return 0;
}


#include<set>
#include<cstdio>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int maxn=200000+5;
std::set<int>S;
int point[2][maxn];
int seq[maxn];
int a[maxn];
bool Max;
int Zero;
int n,q;
inline int Read(){
	register int ret;
	register char r;
	while(r=getchar(),r<'0'||r>'9');ret=r-48;
	while(r=getchar(),r>='0'&&r<='9')ret=(ret<<3)+(ret<<1)+r-48;
	return ret;
}
int main(){
	n=Read(),q=Read();
	memset(point[0],0x3f,sizeof(point[0]));
	for(register int i=1;i<=n;i++){
		a[i]=Read(),
		point[0][a[i]]=min(point[0][a[i]],i);
		point[1][a[i]]=max(point[1][a[i]],i);
	}
	for(register int i=1;i<=n;i++){
		if(a[i]==q)Max=true;
		if(!a[i]){
			if(!S.size())S.insert(1);
			seq[i]=*--S.end();
			Zero=i;
		}
		else{
			if(i==point[0][a[i]]){
				if(S.size()&&
					*--S.end()>a[i])return puts("NO");
				S.insert(a[i]);
			}
			if(i==point[1][a[i]]){
				if(point[0][a[i]]<point[1][a[i]]&&
					seq[i-1]<a[i])return puts("NO");
				S.erase(a[i]);
			}
			seq[i]=a[i];
		}
	}
	if((!Max)&&(!Zero))return puts("NO");
	if(!Max)seq[Zero]=q;puts("YES");
	for(register int i=1;i<=n;i++)
		printf("%d ",seq[i]);
	return 0;
}


#include<set>
#include<cstdio>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int maxn=200000+5;
std::set<int>S;
int seq[maxn];
bool Max;
int Zero;
int n,q;
inline int Read(){
	register int ret;
	register char r;
	while(r=getchar(),r<'0'||r>'9');ret=r-48;
	while(r=getchar(),r>='0'&&r<='9')ret=(ret<<3)+(ret<<1)+r-48;
	return ret;
}
int main(){
	n=Read(),q=Read();
	for(register int i=1;i<=n;i++){
		int num=Read();
		if(num==q)Max=true;
		if(!num){
			if(!S.size())S.insert(1);
			seq[i]=*--S.end();
			Zero=i;
		}
		else{
			if(S.find(num)==S.end()){
				S.insert(num);
				seq[i]=num;
			}
			else{
				if(seq[i-1]<num)return puts("NO");
				seq[i]=num;S.erase(num);
			}
		}
	}
	if((!Max)&&(!Zero))return puts("NO");
	if(!Max)seq[Zero]=q;puts("YES");
	for(register int i=1;i<=n;i++)
		printf("%d ",seq[i]);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int data[N];
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int flag=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&data[i]);
        if(data[i]!=0)
            flag=1;
    }
    if(flag==0)
    {
        printf("YES\n");
        for(int i=0;i<n;i++)
            printf("%d ",q);
        return 0;
    }
    if(data[0]==0)
    {
        for(int i=1;i<n;i++)
            if(data[i]!=0)
            {
                data[0]=data[i];
                break;
            }
    }
    for(int i=1;i<n;i++)
    {
        if(data[i]==0)
            data[i]=data[i-1];
    }
    for(int i=1;i<n-1;i++)
    {
        if(data[i]>data[i-1]&&data[i]>data[i+1])
        {
            printf("NO\n");
            return 0;
        }
    }
    data[n-1]=q;
    printf("YES\n");
    for(int i=0;i<n;i++)
        printf("%d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int data[N];
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int flag=0;
    int flag1=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&data[i]);
        if(data[i]==q)
            flag1=1;
        if(data[i]!=0)
            flag=1;
    }
    if(flag==0)
    {
        printf("YES\n");
        for(int i=0;i<n;i++)
            printf("%d ",q);
        return 0;
    }
    if(data[0]==0)
    {
        for(int i=1;i<n;i++)
            if(data[i]!=0)
            {
                data[0]=data[i];
                break;
            }
    }
    for(int i=1;i<n;i++)
    {
        if(data[i]==0)
            data[i]=data[i-1];
    }
    for(int i=1;i<n-1;i++)
    {
        if(data[i]>data[i-1]&&data[i]>data[i+1])
        {
            printf("NO\n");
            return 0;
        }
    }
    if(flag1==0)
        data[n-1]=q;
    printf("YES\n");
    for(int i=0;i<n;i++)
        printf("%d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int data[N];
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int flag=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&data[i]);
        if(data[i]!=0)
            flag=1;
    }
    if(flag==0)
    {
        printf("YES\n");
        for(int i=0;i<n;i++)
            printf("%d ",q);
        return 0;
    }
    if(data[0]==0)
    {
        for(int i=1;i<n;i++)
            if(data[i]!=0)
            {
                data[0]=data[i];
                break;
            }
    }
    for(int i=1;i<n;i++)
    {
        if(data[i]==0)
            data[i]=data[i-1];
    }
    for(int i=1;i<n-1;i++)
    {
        if(data[i]>data[i-1]&&data[i]>data[i+1])
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    for(int i=0;i<n;i++)
        printf("%d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int data[N];
int vis[N];
int sign[N];
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int flag=0;
    int flag1=0;
    int flag2=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&data[i]);
        if(data[i]==q)
            flag1=1;
        if(data[i]!=0)
            flag=1;
        if(data[i]==0)
            flag2=i;
    }
    if(flag==0)
    {
        printf("YES\n");
        for(int i=0;i<n;i++)
            printf("%d ",q);
        return 0;
    }
    if(data[0]==0)
    {
        for(int i=1;i<n;i++)
            if(data[i]!=0)
            {
                data[0]=data[i];
                break;
            }
    }
    for(int i=1;i<n;i++)
    {
        if(data[i]==0)
            data[i]=data[i-1];
    }
    for(int i=0;i<n;i++)
    {
        if(vis[data[i]])
        {
            if(sign[vis[data[i]]-1])
            {
                printf("NO\n");
                return 0;
            }
        }
        if(i<n-1&&data[i+1]<data[i])
        {
            sign[i]=1;
        }
        vis[data[i]]=i+1;
    }
    if(flag1==0)
    {
        if(flag2!=-1)
            data[flag2]=q;
        else
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    for(int i=0;i<n;i++)
        printf("%d ",data[i]);
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int a[200005];
bool f[200005];
bool ff[200005];
int t[200005];
int ss[200005];
int n,k;
void add(int p,int d)
{
	while (p<=k){
		t[p]+=d;
		p+=p&-p;
	}
}
int sum(int p)
{
	int s=0;
	while(p>0){
		s+=t[p];
		p-=p&-p;
	}
	return s;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int mx=a[1];
	int ll=a[1];
	int lr=a[1];
	int l=0;
	int r=0;
	bool flag=true;
	bool f1=true;
	for(int i=1;i<=n;i++){
		if (a[i]>0){
			if (ll==0){
				ll=a[i];
				l=i;
			}
			lr=a[i];
			r=i;
		}
		if (ll>0 && a[i]==0){
			f1=false;
		}
		mx=max(mx,a[i]);
		if (a[i]>0){
			if (f[a[i]]){
				int x=sum(a[i]);
				if (x-ss[a[i]]>1){
					flag=false;
				}
				ss[a[i]]=x;
			}
			else{
				f[a[i]]=true;
				ss[a[i]]=sum(a[i]);
			}
			add(a[i],1);
		}
	}
	if (flag){
		printf("YES\n");
		if (mx==0){
			for(int i=1;i<=n;i++){
				a[i]=k;
			}
		}
		else{
			if (mx<k){
				bool fl=false;
				for(int i=1;i<=n;i++){
					if (a[i]==0 && i<l){
						if (f1) a[i]=k;
						else a[i]=ll;
					}
					else if (a[i]==0 && i>r){
						if (!fl) a[i]=k;
						else a[i]=lr;
					}
					else if (a[i]==0){
						if (!fl){
							a[i]=k;
							fl=true;
						}
						else a[i]=a[i-1];
					}
				}
			}
			else{
				for(int i=1;i<=n;i++){
					if (a[i]==0 && i<l){
						a[i]=ll;
					}
					else if (a[i]==0 && i>r){
						a[i]=lr;
					}
					else if (a[i]==0){
						a[i]=a[i-1];
					}
				}
			}
		}
		for(int i=1;i<=n;i++){
			cout<<a[i]<<' ';
		}
	}
	else printf("NO");
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int a[200005];
bool f[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int mx=a[1];
	int ll=a[1];
	int lr=a[1];
	int l=0;
	int r=0;
	if (a[1]!=0) f[a[1]]=true;
	bool flag=true;
	bool f1=true;
	for(int i=2;i<=n;i++){
		if (a[i]>0){
			if (ll==0){
				ll=a[i];
				l=i;
			}
			lr=a[i];
			r=i;
		}
		if (ll>0 && a[i]==0){
			f1=false;
		}
		mx=max(mx,a[i]);
		if (a[i]>0){
			if (f[a[i]] && a[i]>a[i-1] && a[i-1]!=0){
				flag=false;
			}
			else f[a[i]]=true;
		}
	}
	if (flag){
		printf("YES\n");
		if (mx==0){
			for(int i=1;i<=n;i++){
				a[i]=k;
			}
		}
		else{
			if (mx<k){
				bool fl=false;
				for(int i=1;i<=n;i++){
					if (a[i]==0 && i<l){
						if (f1) a[i]=k;
						else a[i]=ll;
					}
					else if (a[i]==0 && i>r){
						if (!fl) a[i]=k;
						else a[i]=lr;
					}
					else if (a[i]==0){
						if (a[i+1]==mx){
							a[i]=k;
							fl=true;
						}
						else a[i]=a[i-1];
					}
				}
			}
			else{
				for(int i=1;i<=n;i++){
					if (a[i]==0 && i<l){
						a[i]=ll;
					}
					else if (a[i]==0 && i>r){
						a[i]=lr;
					}
					else if (a[i]==0){
						a[i]=a[i-1];
					}
				}
			}
		}
		for(int i=1;i<=n;i++){
			cout<<a[i]<<' ';
		}
	}
	else printf("NO");
}