#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
//#define mp make_pair
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
#ifndef scanf
#define scanf scanf_s
#endif
#define mp make_pair
//long double pi = acos(-1);
LL mod = 2;
LL QPow(LL a, LL b) { LL ans = 1; while (b) { if (b & 1)ans = ans * a%mod; a = a * a%mod; b >>= 1; }return ans; }
LL inf = (LL)1 << 30;
double eps = 1e-8;
const int msz = 101;
/*int b[msz][msz];
int ans[msz][msz];
int md[msz][msz];
inline LL add(const LL&a, const LL&b)
{
	return (a + b) >= mod ? (a + b) - mod : (a + b < 0 ? a + b + mod : a + b);
}
inline LL mul(const LL&a, const LL&b)
{
	return 1ll * a*b%mod;
}
int nn;
void matrixPow(int n)
{
	int msz = nn;
	while (n)
	{
		if (n&1)
		{
			for(int i=0;i<msz;i++)
				for (int j = 0; j < msz; j++)
				{
					md[i][j] = 0;
					for (int k = 0; k < msz; k++)
						md[i][j] = add(md[i][j], mul(ans[i][k], b[k][j]));
				}
			memcpy(ans, md, sizeof ans);
		}
		for (int i = 0; i < msz; i++)
			for (int j = 0; j < msz; j++)
			{
				md[i][j] = 0;
				for (int k = 0; k < msz; k++)
					md[i][j] = add(md[i][j], mul(b[i][k], b[k][j]));
			}
		memcpy(b, md, sizeof b);
		n >>= 1;
	}
}*/
#define N 2
struct matrix
{
	LL m[N][N];
};
matrix b1, ans;
matrix mul(matrix a, matrix b)
{
	int i, j, k;
	matrix c;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
		{
			c.m[i][j] = 0;
			for (int k = 0; k < N; k++)
				c.m[i][j] += (a.m[i][k] * b.m[k][j]) % mod, c.m[i][j] %= mod;

		}
	return c;
}
void mpow(matrix b, int n)
{
	int i;
	mes(ans.m);
	for (int i = 0; i < N; i++)
		ans.m[i][i] = 1 % mod;
	for (; n; n >>= 1)
	{
		if (n & 1)
			ans = mul(ans, b);
		b = mul(b, b);
	}
}
//char str[102];
int arr[200002];
int mxf[200002];
int mxb[200002];
bool f[200002];
bool b[200002];
//int mnf[200002];
//int mnb[200002];
signed main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t;
	int n;
	int q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)cin >> arr[i];
	int maxn = 0;
	//int minn = q + 5;
	bool zr = 0, mx = 0;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] == q)mx = 1;
		if (arr[i] == 0)zr = 1;
	}
	bool flag = 1;
	for (int i = n - 1; i >= 0; i--)
	{
		if (arr[i] == 0)continue;
		if (arr[i] > maxn)
			mxb[i] = maxn = arr[i];
		else if (arr[i] < maxn)
			b[i] = 1;
		if (i < n - 1)f[i] |= f[i + 1];
		mxb[i] = maxn;
	}
	maxn = 0;
	//minn = q + 5;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] == 0)
			continue;
		if (arr[i] > maxn)
			mxf[i] = maxn = arr[i];
		else if (arr[i] < maxn)
			f[i] = 1;
		if (i > 0)f[i] |= f[i-1];
		mxf[i] = maxn;
	}
	for (int i = 0; i < n; i++)
		if (arr[i])
			if (mxb[i] > arr[i] && mxf[i] > arr[i])
				flag = 0;
	if (zr == 0 && mx == 0)
		flag = 0;
	int mxid = -1;
	for (int i = 0; i < n; i++)
		if (arr[i] == q)mxid = i;
	if (mxid == -1)
		if (zr)
			for (int i = 0; i < n; i++)
				if (arr[i] == 0&&!f[i]&&!b[i])
					mxid = i, arr[i] = q;
	if (mxid == -1)flag = 0, mxid = 0;
	for (int i = 0; i < mxid; i++)
	{
		if (arr[i])continue;
		if (i == 0)
		{
			arr[i] = 1;
			continue;
		}
		arr[i] = arr[i - 1];
	}
	for (int i = n-1; i >mxid; i--)
	{
		if (arr[i])continue;
		if (i == n - 1)
		{
			arr[i] = 1;
			continue;
		}
		arr[i] = arr[i + 1];
	}
	for (int i = 1; i < n - 1; i++)
		if (arr[i]<arr[i - 1] && arr[i + 1]>arr[i])
			flag = 0;
	if (!flag)
		cout << "NO\n";
	else
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << arr[i] << " ";

	}
//	system("pause");
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
//#define mp make_pair
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
#ifndef scanf
#define scanf scanf_s
#endif
#define mp make_pair
//long double pi = acos(-1);
LL mod = 2;
LL QPow(LL a, LL b) { LL ans = 1; while (b) { if (b & 1)ans = ans * a%mod; a = a * a%mod; b >>= 1; }return ans; }
LL inf = (LL)1 << 30;
double eps = 1e-8;
const int msz = 101;
/*int b[msz][msz];
int ans[msz][msz];
int md[msz][msz];
inline LL add(const LL&a, const LL&b)
{
	return (a + b) >= mod ? (a + b) - mod : (a + b < 0 ? a + b + mod : a + b);
}
inline LL mul(const LL&a, const LL&b)
{
	return 1ll * a*b%mod;
}
int nn;
void matrixPow(int n)
{
	int msz = nn;
	while (n)
	{
		if (n&1)
		{
			for(int i=0;i<msz;i++)
				for (int j = 0; j < msz; j++)
				{
					md[i][j] = 0;
					for (int k = 0; k < msz; k++)
						md[i][j] = add(md[i][j], mul(ans[i][k], b[k][j]));
				}
			memcpy(ans, md, sizeof ans);
		}
		for (int i = 0; i < msz; i++)
			for (int j = 0; j < msz; j++)
			{
				md[i][j] = 0;
				for (int k = 0; k < msz; k++)
					md[i][j] = add(md[i][j], mul(b[i][k], b[k][j]));
			}
		memcpy(b, md, sizeof b);
		n >>= 1;
	}
}*/
#define N 2
struct matrix
{
	LL m[N][N];
};
matrix b1, ans;
matrix mul(matrix a, matrix b)
{
	int i, j, k;
	matrix c;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
		{
			c.m[i][j] = 0;
			for (int k = 0; k < N; k++)
				c.m[i][j] += (a.m[i][k] * b.m[k][j]) % mod, c.m[i][j] %= mod;

		}
	return c;
}
void mpow(matrix b, int n)
{
	int i;
	mes(ans.m);
	for (int i = 0; i < N; i++)
		ans.m[i][i] = 1 % mod;
	for (; n; n >>= 1)
	{
		if (n & 1)
			ans = mul(ans, b);
		b = mul(b, b);
	}
}
//char str[102];
int arr[200002];
int mxf[200002];
int mxb[200002];
bool f[200002];
bool b[200002];
//int mnf[200002];
//int mnb[200002];
signed main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t;
	int n;
	int q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)cin >> arr[i];
	int maxn = 0;
	bool zr = 0, mx = 0;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] == q)mx = 1;
		if (arr[i] == 0)zr = 1;
	}
	bool flag = 1;
	for (int i = n - 1; i >= 0; i--)
	{
		if (i < n - 1)f[i] |= f[i + 1];
		if (arr[i] == 0)continue;
		if (arr[i] > maxn)
			mxb[i] = maxn = arr[i];
		else if (arr[i] < maxn)
			b[i] = 1;
		if (i < n - 1)f[i] |= f[i + 1];
		mxb[i] = maxn;
	}
	maxn = 0;
	for (int i = 0; i < n; i++)
	{
		if (i > 0)f[i] |= f[i - 1];
		if (arr[i] == 0)
			continue;
		if (arr[i] > maxn)
			mxf[i] = maxn = arr[i];
		else if (arr[i] < maxn)
			f[i] = 1;
		if (i > 0)f[i] |= f[i-1];
		mxf[i] = maxn;
	}
	for (int i = 0; i < n; i++)
		if (arr[i])
			if (mxb[i] > arr[i] && mxf[i] > arr[i])
				flag = 0;
	if (zr == 0 && mx == 0)
		flag = 0;
	int mxid = -1;
	for (int i = 0; i < n; i++)
		if (arr[i] == q)mxid = i;
	if (mxid == -1)
		if (zr)
			for (int i = 0; i < n; i++)
				if (arr[i] == 0&&!f[i]&&!b[i])
					mxid = i, arr[i] = q;
	if (mxid == -1)flag = 0, mxid = 0;
	for (int i = 0; i < mxid; i++)
	{
		if (arr[i])continue;
		if (i == 0)
		{
			arr[i] = 1;
			continue;
		}
		arr[i] = arr[i - 1];
	}
	for (int i = n-1; i >mxid; i--)
	{
		if (arr[i])continue;
		if (i == n - 1)
		{
			arr[i] = 1;
			continue;
		}
		arr[i] = arr[i + 1];
	}
	for (int i = 1; i < n - 1; i++)
		if (arr[i]<arr[i - 1] && arr[i + 1]>arr[i])
			flag = 0;
	if (!flag)
		cout << "NO\n";
	else
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << arr[i] << " ";

	}
//	system("pause");
	return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(f[a1] <l[a2] && l[a2] <  l[a1] && f[a2] < f[a1] || f[a2] <l[a1] && l[a1] <  l[a2] && f[a1] < f[a2])
    {
        cout<<"NO";
        exit(0);
    }
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 < l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        if(m[i] != 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    vector<int> vec2 = vec;
    vec.clear();
    for(int i = 1; i <= c; ++i)
        if(m[i] == 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    vec = vec2;
    if(vec[0] == -1)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == -1)
                vec[i] = vec[i+1];
    }

    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == -1)
                vec[i] = vec[i-1];
    }

    for(int i = 0 ; i < n; ++i)
        if(vec[i] == -1) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq,isz;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(a[i] == 0) isz++;
        if(!a[i]) continue;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!a[i]) continue;
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }
    if(isz == 0 && isq == 0) return cout<<"NO",0;
    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if(s.top() > a[i])
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(!isq)
        for(int i = 1; i <= n; ++i)
        if(!a[i])
    {
        a[i] = q;
        break;
    }
    for(int i = 1; i <= n; ++i)
        if(a[i] == 0)
            a[i] = a[i-1];
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 1; i <= c; ++i)
        cout<<m[i]<<' ';
    for(int i = 2; i < c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;

    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1])
    {
        if(a2 == 0) return 1;
        if(a1 == 0) return 0;
        return a1<a2;
    }
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;

    if(m[c] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q]!=0 ? vec[i-1] : q;
    }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq,isz;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(a[i] == 0) isz++;
        if(!a[i]) continue;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!a[i]) continue;
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }
    if(isz == 0 && isq == 0) return cout<<"NO",0;
    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if(s.top() > a[i])
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
        if(!l[i] && !r[i])
        {
            if(a[i] != 0)
            {
                if(s.top() != a[i])
                    return cout<<"NO",0;
            }
        }
    }
    cout<<"YES"<<endl;
    if(!isq)
        for(int i = 1; i <= n; ++i)
        if(!a[i])
    {
        a[i] = q;
        break;
    }
    for(int i = 1; i <= n; ++i)
        if(a[i] == 0)
            a[i] = a[i-1];
    for(int i = n; i >= 1; --i)
        if(a[i] == 0)
            a[i] = a[i+1];
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1])
    {
        if(a2 == 0) return 1;
        if(a1 == 0) return 0;
        return a1<a2;
    }
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;

    if(m[c] != 0 && f[0]) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    if(vec[n-1] == 0)
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q] ? vec[i-1] : q;
    }
    for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q] ? vec[i-1] : q;
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(f[a1] <l[a2] && l[a2] <  l[a1] && f[a2] < f[a1] || f[a2] <l[a1] && l[a1] <  l[a2] && f[a1] < f[a2])
    {
        cout<<"NO";
        exit(0);
    }
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 < l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        if(m[i] != 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    vector<int> vec2 = vec;
    vec.clear();
    for(int i = 1; i <= c; ++i)
        if(m[i] == 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    vec = vec2;
    if(vec[0] == -1)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == -1)
                vec[i] = f[q]? vec[i+1] : q;
    }

    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == -1)
                vec[i] = f[q]? vec[i-1] : q;
    }

    for(int i = 0 ; i < n; ++i)
        if(vec[i] == -1) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1])
    {
        if(a2 == 0) return 1;
        if(a1 == 0) return 0;
        return a1<a2;
    }
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;

    if(m[c] != 0 && f[0]) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                {
                    if(f[q])
                        vec[i] = vec[i+1];
                    else vec[i] = q;
                }
    }
    if(vec[n-1] == 0)
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                {
                    if(f[q])
                        vec[i] = vec[i-1];
                    else vec[i] = q;
                }
    }
    for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                {
                    if(f[q])
                        vec[i] = vec[i-1];
                    else vec[i] = q;
                }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq,isz;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(a[i] == 0) isz++;
        if(!a[i]) continue;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!a[i]) continue;
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }
    if(isz == 0 && isq == 0) return cout<<"NO",0;
    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if(s.top() > a[i])
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(!isq)
        for(int i = 1; i <= n; ++i)
        if(!a[i])
    {
        a[i] = isq;
        break;
    }
    for(int i = 1; i <= n; ++i)
        if(a[i] == 0)
            a[i] = a[i-1];
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }

    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if((s.top() > a[i] && a[i] != 0) || (s.top() == 0))
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(a[1]!=0)
    for(int i = 2; i <= n; ++i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i-1];

    if(a[n]!=0)
    for(int i = n-1; i >= 1; --i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i+1];

    for(int i = 1; i <= n; ++i)
        if(a[i] == 0) a[i] = q;

        if(n>99)
            for(int i = n - 29; i <= n; ++i) cout<<a[i]<<' ';
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1])
    {
        if(a2 == 0) return 1;
        if(a1 == 0) return 0;
        return a1<a2;
    }
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;

    if(m[c] != 0 && f[0]) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    if(vec[n-1] == 0)
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q] ? vec[i-1] : q;
    }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }

    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if((s.top() > a[i] && a[i] != 0) || (s.top() == 0))
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(a[1]!=0)
    for(int i = 2; i <= n; ++i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i-1];

    if(a[n]!=0)
    for(int i = n-1; i >= 1; --i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i+1];

    for(int i = 1; i <= n; ++i)
        if(a[i] == 0) a[i] = q;

        if(n>99)
            for(int i = n - 49; i <= n; ++i) cout<<a[i]<<' ';
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }

    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if((s.top() > a[i] && a[i] != 0) || (s.top() == 0))
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(a[1]!=0)
    for(int i = 2; i <= n; ++i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i-1];

    if(a[n]!=0)
    for(int i = n-1; i >= 1; --i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i+1];

    for(int i = 1; i <= n; ++i)
        if(a[i] == 0) a[i] = q;

    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i < c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q]!=0 ? vec[i-1] : q;
    }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q]!=0 ? vec[i-1] : q;
    }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq,isz;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(a[i] == 0) isz++;
        if(!a[i]) continue;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!a[i]) continue;
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }
    if(isz == 0 && isq == 0) return cout<<"NO",0;
    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if(s.top() > a[i])
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(!isq)
        for(int i = 1; i <= n; ++i)
        if(!a[i])
    {
        a[i] = q;
        break;
    }
    for(int i = 1; i <= n; ++i)
        if(a[i] == 0)
            a[i] = a[i-1];
    for(int i = n; i >= 1; --i)
        if(a[i] == 0)
            a[i] = a[i+1];
    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(f[a1] <l[a2] && l[a2] <  l[a1] && f[a2] < f[a1] || f[a2] <l[a1] && l[a1] <  l[a2] && f[a1] < f[a2])
    {
        cout<<"NO";
        exit(0);
    }
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    return l[a1] - f[a1] + 1 < l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    a[0] = -1;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(a[i] == 0 && a[i-1]!=0) k++;
        if(!f[a[i]])f[a[i]] = i;
        l[a[i]] = i;
    }
    if(k>1) return cout<<"NO",0;
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        if(m[i] != 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1] && a[i+1] != 0) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == -1)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == -1)
                vec[i] = vec[i+1];
    }

    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == -1)
                vec[i] = vec[i-1];
    }

    for(int i = 0 ; i < n; ++i)
        if(vec[i] == -1) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1])
    {
        if(a2 == 0) return 1;
        if(a1 == 0) return 0;
        return a1<a2;
    }
    return l[a1] - f[a1] + 1 > l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(!f[a[i]]) f[a[i]] = i;
        l[a[i]] = i;
    }
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0) return cout<<"NO",0;

    if(m[c] != 0 && f[0]) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1]) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == 0)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == 0)
                vec[i] = f[q]? vec[i+1] : q;
    }
    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == 0)
                vec[i] = f[q]!=0 ? vec[i-1] : q;
    }
    for(int i = 0 ; i < n; ++i)
        if(vec[i] == 0) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],used[DIM],l[DIM],r[DIM],isq,isz;
stack<long long> s;
int main()
{
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];

    for(int i = 1; i <= n; ++i)
    {
        if(a[i] == q) isq++;
        if(a[i] == 0) isz++;
        if(!used[a[i]])
            l[i] = 1;
        used[a[i]] = 1;
    }
    memset(used,0,sizeof(used));
    for(int i = n; i >= 1; --i)
    {
        if(!used[a[i]])
            r[i] = 1;
        used[a[i]] = 1;
    }
    if(isz == 0 && isq == 0) return cout<<"NO",0;
    for(int i = 1; i <= n; ++i)
    {
        if(l[i])
        {
            if(s.size())
                if((s.top() > a[i] && a[i] != 0) || (s.top() == 0))
                    return cout<<"NO",0;
            s.push(a[i]);
        }
        if(r[i])
        {
            if(s.top() != a[i]) return cout<<"NO",0;
            s.pop();
        }
    }
    cout<<"YES"<<endl;
    if(a[1]!=0)
    for(int i = 2; i <= n; ++i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i-1];

    if(a[n]!=0)
    for(int i = n-1; i >= 1; --i)
        if(a[i] == 0)
            a[i] = !isq? q:a[i+1];

    for(int i = 1; i <= n; ++i)
        if(a[i] == 0) a[i] = q;

    for(int i = 1; i <= n; ++i)
        cout<<a[i]<<' ';

    return 0;
}


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

long long n,q,a[DIM],f[DIM],l[DIM],m[DIM],c,k;
bool cmp(int a1,int a2)
{
    if(l[a1] < f[a2] || l[a2] < f[a1]) return a1<a2;
    if(l[a1] - f[a1] + 1 == l[a2] - f[a2] + 1) return a1 < a2;
    else return l[a1] - f[a1] + 1 < l[a2] - f[a2] + 1;
}

long long tree[4*DIM];

void push(int v,int tl,int tr)
{
    if(tl == tr || tree[v] == - 1) return;
    tree[v*2+1] = tree[v*2+2] = tree[v];
    tree[v] = -1;
}
void update(int v,int tl,int tr,int l,int r,int val)
{
    if(tl > r|| tr < l) return;

    if(l <= tl && tr <= r)
    {
        tree[v] = val;
        return;
    }

    push(v,tl,tr);
    int tm = (tl + tr) / 2;
    update(v*2+1,tl,tm,l,r,val);
    update(v*2+2,tm+1,tr,l,r,val);
}

vector<int> vec;
void getm(int v,int tl,int tr)
{
    if(tl == tr)
        vec.push_back(tree[v]);
    else
    {
        push(v,tl,tr);
        int tm = (tl + tr) / 2;
        getm(v*2+1,tl,tm);
        getm(v*2+2,tm+1,tr);
    }

}

int main()
{
    cin>>n>>q;
    a[0] = -1;
    for(int i = 1; i <= n; ++i)
    {
        cin>>a[i];
        if(a[i] == 0 && a[i-1]!=0) k++;
        if(!f[a[i]])f[a[i]] = i;
        l[a[i]] = i;
    }
    if(k>1) return cout<<"NO",0;
    for(int i = 0; i <= q; ++i)
        if(f[i])
        {
            m[++c] = i;
        }
    sort(m+1,m+c+1,cmp);
    for(int i = 2; i <= c; ++i)
        if(m[i] < m[i-1] && m[i] != 0 && m[i-1] != 0) return cout<<"NO",0;
    memset(tree,-1,sizeof(tree));

    for(int i = 1; i <= c; ++i)
    {
        if(m[i] != 0) update(0,1,n,f[m[i]],l[m[i]],m[i]);
    }
    getm(0,1,n);
    for(int i = 0; i < n; ++i)
        if(vec[i] != a[i+1] && a[i+1] != 0) return cout<<"NO",0;

    cout<<"YES"<<endl;
    if(vec[0] == -1)
    {
        for(int i = n - 2; i >=0; --i)
            if(vec[i] == -1)
                vec[i] = vec[i+1];
    }

    else
    {
        for(int i = 1; i <=n-1; ++i)
            if(vec[i] == -1)
                vec[i] = vec[i-1];
    }

    for(int i = 0 ; i < n; ++i)
        if(vec[i] == -1) vec[i] = q;
    for(int i = 0; i < n; ++i)
        cout<<vec[i]<<' ';

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	int maks = 0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		maks = max(maks, a[i]);
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	bool ada0 = false;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){
			ada0 = true;
			continue;
		}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign <= a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(!ada0){
		if(maks != q){
			printf("NO\n");
			return 0;
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == q){
			isThereq = true;
		}
	}

	vi listBil;
	int last = q;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign < a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign < a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == q){
			isThereq = true;
		}
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign < a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign < a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	vi list0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i] == 0){
			list0.pb(i);
			a[i] = maxn;
		}
		isVisited[a[i]] = true;
	}

	AdjList.assign(maxn + 10,vi());

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}

	for(i=0;i<list0.size();i++){
		a[list0[i]] = 0;
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		listBil.pb(last);
	}

	bool semua0 = true;
	bool ada0 = false;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){
			ada0 = true;
			continue;
		}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign <= a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(!ada0){
		if(!isVisited[q]){
			printf("NO\n");
			return 0;
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	scanf("%d %d",&n,&q);

	for(i=1;i<=n;i++){scanf("%d",&a[i]);}
	AdjList.assign(maxn,vi());

	for(i=1;i<=n;i++){
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	vi listIdx0;
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == 0){
			listIdx0.pb(i);
			a[i] = maxn;
		}
		if(a[i] == q){
			isThereq = true;
		}

	}

	AdjList.assign(maxn + 10,vi());

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		if(AdjList[i].size() == 1){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}

	for(i=0;i<listIdx0.size();i++){
		a[listIdx0[i]] = 0;
	}

	AdjList.clear();

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign < a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign < a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	vi listIdx0;
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == 0){
			listIdx0.pb(i);
			a[i] = maxn;
		}
		if(a[i] == q){
			isThereq = true;
		}

	}

	AdjList.assign(maxn + 10,vi());

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		if(AdjList[i].size() == 1){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}

	for(i=0;i<listIdx0.size();i++){
		a[listIdx0[i]] = 0;
	}

	AdjList.clear();

	vi listBil;
	int last = q;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign < a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign < a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == q){
			isThereq = true;
		}
	}

	vi listBil;
	int last = q;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				idx++;
				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			idx++;
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn + 10];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	vi list0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i] == 0){
			list0.pb(i);
			a[i] = maxn;
		}
		isVisited[a[i]] = true;
	}

	AdjList.assign(maxn + 10,vi());

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}

	for(i=0;i<list0.size();i++){
		a[list0[i]] = 0;
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		listBil.pb(last);
	}

	bool semua0 = true;
	bool ada0 = false;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){
			ada0 = true;
			continue;
		}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign <= a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(!ada0){
		if(!isVisited[q]){
			printf("NO\n");
			return 0;
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);

	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;

	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign <= a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i] == q){
			isThereq = true;
		}
	}
	AdjList.assign(maxn,vi());
	bool semua0 = true;
	bool assigned = false;
	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(!isThereq){
				if(assigned){
					assign = a[i];
				}else{
					assign = q;
				}

			}else{
				assign = a[i];
			}

			if(i!=1){
				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
						if(assign = q){
							assigned = true;
						}
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);
			if(!isThereq){
				if(assigned){
					assign = a[i];
				}else{
					assign = q;
				}

			}else{
				assign = a[i];
			}
			if(i==n){continue;}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
					if(assign == q){
						assigned = true;
					}
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		listBil.pb(last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	bool ada0 = false;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){
			ada0 = true;
			continue;
		}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign <= a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(!ada0){
		if(!isVisited[q]){
			printf("NO\n");
			return 0;
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i] == q){
			isThereq = true;
		}
	}
	AdjList.assign(maxn,vi());
	bool semua0 = true;
	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(!isThereq){
				assign = q;
			}else{
				assign = a[i];
			}

			if(i!=1){
				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);
			if(!isThereq){
				assign = q;
			}else{
				assign = a[i];
			}
			if(i==n){continue;}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		if(AdjList[i].size() == 0){continue;}
		for(j=0;j<(AdjList[i].size()-1);j++){
			int idx1 = AdjList[i][j];
			int idx2 = AdjList[i][j+1];
			if(idx1 == (idx2-1)){continue;}
			int minim = query(1,1,n,idx1 + 1, idx2 - 1);
			if(minim < i){printf("NO\n"); return 0;}
		}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn + 10];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	a[0] = -1; a[n+1] = -1;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
	}

	vi listBil;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		listBil.pb(1);
	}

	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}

			for(j=i-1;j>=1;j--){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
		if(a[i+1] == 0){
			assign = listBil[idx];
			if(assign <= a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(!isVisited[0]){
		if(!isVisited[q]){
			printf("NO\n");
			return 0;
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	AdjList.assign(maxn + 10,vi());

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		int ukuran = AdjList[i].size();
		if(ukuran <= 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}

	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn];

int st[maxn*4];

int left(int n){return 2*n;}
int right(int n){return 2*n + 1;}

void build(int node, int l, int r){
	if(l == r){
		st[node] = a[l];
	}else{
		int mid = (l+r)/2;
		build(left(node), l, mid);
		build(right(node), mid+1, r);

		st[node] = min(st[left(node)], st[right(node)]);
	}
}

int query(int node, int l, int r, int i, int j){
	if(r < i || l > j){return inf;}
	if(i<=l && r<=j){return st[node];}
	int mid = (l+r)/2;
	int ans1 = query(left(node), l, mid, i, j);
	int ans2 = query(right(node), mid+1, r, i, j);
	return min(ans1,ans2);
}

vector<vi> AdjList;

int main(){
	int n,q,i,j;
	bool isVisited[maxn];
	memset(isVisited, false, sizeof isVisited);
	scanf("%d %d",&n,&q);
	bool isThereq = false;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		isVisited[a[i]] = true;
		if(a[i] == q){
			isThereq = true;
		}
	}

	vi listBil;
	int last = 1;
	for(i=q;i>=1;i--){
		if(!isVisited[i]){
			listBil.pb(i);
			last = i;
			// printf("dipush: %d\n",last);
		}
	}

	int ukuran = listBil.size();
	int sisa = n - ukuran;
	for(i=0;i<sisa;i++){
		last--;
		if(last == 0){last = 1;}
		listBil.pb(last);
		// printf("dipush: %d\n",last);
	}

	AdjList.assign(maxn,vi());
	bool semua0 = true;
	int idx = 0;

	for(i=1;i<=n;i++){
		if(a[i] == 0){continue;}
		// printf("i: %d sebelum: %d sesudah: %d\n",i,a[i-1],a[i+1]);
		int assign = 0;
		semua0 = false;
		if(a[i-1] == 0){
			// printf("masuk sini\n");

			if(i!=1){
				assign = listBil[idx];
				if(assign < a[i]){
					assign = a[i];
				}else{
					idx++;
				}

				for(j=i-1;j>=1;j--){
					if(a[j] == 0){
						a[j] = assign;
					}else{
						break;
					}
				}
			}

		}
		if(a[i+1] == 0){
			// printf("i: %d masuk sini\n",i);

			if(i==n){continue;}
			assign = listBil[idx];
			if(assign < a[i]){
				assign = a[i];
			}else{
				idx++;
			}
			for(j=i+1;j<=n;j++){
				if(a[j] == 0){
					a[j] = assign;
				}else{
					break;
				}
			}
		}
	}

	if(semua0){
		for(i=1;i<=n;i++){
			a[i] = q;
		}
	}

	for(i=1;i<=n;i++){
		// printf("elemen: %d\n",a[i]);
		int maks = -1;
		if(a[i] == 0){
			maks = max(maks, a[i-1]);
			maks = max(maks, a[i+1]);
			if(maks == 0){
				a[i] = 1;
			}else{
				a[i] = maks;
			}
		}
	}

	for(i=1;i<=n;i++){
		AdjList[a[i]].pb(i);
	}

	build(1,1,n);

	for(i=1;i<=q;i++){
		//cari tetangga
		// printf("i: %d\n",i);
		int ukuran = AdjList[i].size();
		if(ukuran == 0 || ukuran == 1){continue;}
		int idx1 = AdjList[i][0];
		int idx2 = AdjList[i][ukuran-1];
		if(idx1 == (idx2-1)){continue;}
		int minim = query(1,1,n,idx1 + 1, idx2 - 1);
		if(minim < i){printf("NO\n"); return 0;}
	}
	printf("YES\n");
	for(i=1;i<=n;i++){
		if(i>1){printf(" ");}
		printf("%d",a[i]);
	}
	printf("\n");

	return 0;
};


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(ans[i]==1)
            flag=1;
        if(ans[i] == 0)
            flag1++;
        change(1,1,n,i,ans[i]);
    }
    if(flag1 == 0 && flag) {
        printf("NO\n");
        return 0;
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
int lazy[200500<<2];
int lef[200500];
int righ[200500];
void pushDOWN(int rt)
{
    if(lazy[rt]) {
        lazy[rt<<1] = lazy[rt<<1|1] = lazy[rt];
        tree[rt<<1] = tree[rt<<1|1] = lazy[rt];
        lazy[rt] = 0;
    }
}
void build(int p, int l, int r)
{
    lazy[p] = 0;
    if (l == r) {tree[p] = 0; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
}
void change(int p, int l, int r, int x, int y, int num)
{
    if(x <= l && r <= y) {lazy[p] = num; tree[p] = num; return ;}
    pushDOWN(p);
    int mid = (l + r) / 2;
    if (y <= mid) change(p * 2, l, mid, x, y, num);
    else if(x > mid) change(p * 2 + 1, mid + 1, r, x, y, num);
    else change(p * 2, l, mid, x, y, num),change(p * 2 + 1, mid + 1, r, x, y, num);
}
int find(int p, int l, int r, int x)
{
    if(l == r) return tree[p];
    pushDOWN(p);
    int mid = (l + r) / 2;
    if (x <= mid) return find(p * 2, l, mid, x);
    else return find(p * 2 + 1, mid + 1, r, x);
}
int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0, flag2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(!lef[ans[i]])
            lef[ans[i]]=i;
        righ[ans[i]]=i;
        if(ans[i]==q)
            flag=1;
        if(ans[i]>q)
            flag2=1;
        if(ans[i] == 0)
            flag1++;
    }
    if((flag1==0&&!flag)||flag2) {
        printf("NO\n");
        return 0;
    }
    for(int i = 1; i <= q; i++) {
            if(lef[i]!=0)
            change(1,1,n,lef[i],righ[i],i);
    }
    for(int i = 1; i <= n; i++)
    {
        if(ans[i] == 0)
            continue;
        if(find(1,1,n,i)!=ans[i]) {
            cout<<i<<" "<<ans[i]<<" "<<find(1,1,n,i)<<endl;            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int tree[200500<<2];
struct Num
{
    int ans;
    int id;
}num[200500];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}
int cmp(Num a, Num b)
{
    if(a.ans == b.ans)
        return a.id<b.id;
    return a.ans< b.ans;
}

int cmp1(Num a, Num b)
{
    return a.id<b.id;
}
int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0, flag2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&num[i].ans);
        num[i].id = i;
        if(num[i].ans == q)
            flag = 1;
        if(num[i].ans > q)
            flag2 = 1;
        if(num[i].ans == 0)
            flag1 = i;
        change(1,1,n,i,num[i].ans);
    }
    if((flag1 == 0 && !flag )|| flag2) {
        printf("NO\n");
        return 0;
    }
    for(int i = 2; i < n; i++)
    {
        if(num[i].ans == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(num[i].ans < lm && num[i].ans < rm) {
            printf("NO\n");
            return 0;
        }
    }
    sort(num+1, num+n+1, cmp);
    for(int i = 2; i <= n; i++)
        if(num[i].ans == num[i-1].ans && !num[i].ans){
            int m = find(1,1,n,num[i-1].id,num[i].id);
            if(m > num[i].ans) {
                printf("NO\n");
                return 0;
            }
        }
    printf("YES\n");
    sort(num+1, num+n+1, cmp1);
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(num[i].ans == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                num[i].ans = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(num[pos].ans==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",num[pos].ans);
                i = pos - 1;
            }
            else {
                printf("%d ",num[i-1].ans);
                num[i].ans = num[i-1].ans;
            }
        }
        else
            printf("%d ",num[i].ans);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int res[200500];
int tree[200500<<2];
int main()
{
    int n, q;
    cin>>n>>q;
    int flag = 0,flag1=0, flag2=0;
    int pos = 1;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(ans[i] != 0)
            res[pos++] = ans[i];
        if(ans[i]==q)
            flag=1;
        if(ans[i]>q)
            flag2=1;
        if(ans[i] == 0)
            flag1++;
    }
    if((flag1 == 0 && !flag )|| flag2) {
        printf("NO\n");
        return 0;
    }
    int tot = 1;
    while(1) {
        if(res[tot+1] >= res[tot])
            tot++;
        else
            break;
    }
    while(tot < pos - 1) {
        if(res[tot+1] <= res[tot])
            tot++;
        if(res[tot+1] > res[tot]) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        change(1,1,n,i,ans[i]);
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            pos = i;
        while(ans[pos]==0){
            pos++;
            if(pos > n) {
                ans[pos] = q;
                break;
            }
        }
        for(int j = i; j<pos ;j++)
            printf("%d ",ans[pos]);
            i = pos - 1;
        }
        else
        printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}