#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			{
	 				a[j]=q;
	 				maxi=q;
	 			}
	 		for(i=2;i<=n;i++)
	 			if(!a[i])
					{ if(maxi==q)
	 					a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{

		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk)
			for (int i = 0; i < n; i++)
				if (v[i] == 0)
				{
					for (int j = i; j < n && v[j] == 0; j++)
						v[j] = q;
					break;
				}
		for (int i = 0; i < n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO\n\n\n\n";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n-1]!=0)
		{
			cout << "NO";
			return 0;
		}
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	cout << "YES\n";
	if (se.size() == 0)
		for (int i = 0; i < n; i++)
			cout << q << " ";
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
			{
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
				if (i < n - 1 && v[i + 1] == 0)
					for (int j = i + 1; j < n && v[j] == 0; j++)
						v[j] = v[i];
			}
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{

		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk)
			for (int i = 0; i < n; i++)
				if (v[i] == 0)
				{
					for (int j = i; j < n && v[j] == 0; j++)
						v[j] = q;
					break;
				}
		for (int i = 0; i < n; i++)
			if (v[i] != 0)
			{
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
				if (i + 1 < n && v[i + 1] == 0)
					for (int j = i + 1; j < n && v[j] == 0; j++)
						v[j] = v[i];
			}
		chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk)
		{
			cout << "NO";
			return 0;
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

//	_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO\n\n\n\n";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] == 0)
			{
				for (int j = i; j < n && v[j] == 0; j++)
					v[j] = q;
				break;
			}
		for (int i = 0; i < n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO\n\n\n\n";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	cout << "YES\n";
	if (se.size() == 0)
		for (int i = 0; i < n; i++)
			cout << q << " ";
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		for (int i = n - 1; i >= 0 && v[i] == 0; i--)
			v[i] = q;
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO ff";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int i = l; i <= r; i++)
				se.insert(i);
		}
	cout << "YES\n";
	if (se.size() == 0)
		for (int i = 0; i < n; i++)
			cout << q << " ";
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
			{
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
				if (i < n - 1 && v[i + 1] == 0)
					for (int j = i + 1; j < n && v[j] == 0; j++)
						v[j] = v[i];
			}
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

//	_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	cout << "YES\n";
	if (se.size() == 0)
		for (int i = 0; i < n; i++)
			cout << q << " ";
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		for (int i = n - 1; i >= 0 && v[i] == 0; i--)
			v[i] = q;
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == 0)
			{
				cout << "NO";
				return 0;
			}
			else
				if (v[i] == q)
					chk = 1;
		if (!chk)
		{
			cout << "NO";
			return 0;
		}
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{
		for (int i=0; i<n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		for (int i = n - 1; i >= 0 && v[i] == 0; i--)
			v[i] = q;
		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == 0)
			{
				cout << "NO";
				return 0;
			}
			else
				if (v[i] == q)
					chk = 1;
		if (!chk)
		{
			cout << "NO";
			return 0;
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

//	_getch();
	return 0;
}


#include <stdio.h>
//#include <conio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long LL;
int n, q;
vector<int> v;
vector<vector<int>> v2;
set<int> se;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	v.resize(n);
	v2.resize(q + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i], v2[v[i]].push_back(i);
	for (int i = 1; i <= q; i++)
		if (!v2[i].empty())
		{
			set<int>::iterator it;
			int l, r;
			l = v2[i][0], r = v2[i][v2[i].size() - 1];
			it = se.lower_bound(l);
			if (it != se.end() && *it <= r)
			{
				cout << "NO";
				return 0;
			}
			it = se.upper_bound(r);
			if (it != se.begin())
			{
				it--;
				if (*it >= l)
				{
					cout << "NO";
					return 0;
				}
			}
			for (int j = 0; j < v2[i].size(); j++)
				se.insert(v2[i][j]);
		}
	if (se.size() == 0)
	{
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << q << " ";
	}
	else
	{

		int chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk)
			for (int i = 0; i < n; i++)
				if (v[i] == 0)
				{
					for (int j = i; j < n && v[j] == 0; j++)
						v[j] = q;
					break;
				}
		for (int i = 0; i < n; i++)
			if (v[i] != 0)
				if (i > 0 && v[i - 1] == 0)
					for (int j = i - 1; j >= 0 && v[j] == 0; j--)
						v[j] = v[i];
		chk = 0;
		for (int i = 0; i < n; i++)
			if (v[i] == q)
				chk = 1;
		if (!chk && v[n - 1] != 0)
			if (v[0] != 0)
			{
				cout << "NO\n\n\n\n";
				return 0;
			}
			else
				for (int i = 0; i < n && v[i] == 0; i++)
					v[i] = q;
		if (!chk && v[n - 1] == 0)
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = q;
		if (chk && v[n - 1] == 0)
		{
			set<int>::iterator it;
			it = se.end();
			it--;
			for (int i = n - 1; i >= 0 && v[i] == 0; i--)
				v[i] = v[*it];
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++)
			cout << v[i] << " ";
	}

	//_getch();
	return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
   int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else
        {
            if(!p){a[i]=q;p=true;pre=q;}
            if(pre!=-1){a[i]=pre;}
    }
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
     if(!p)
    {cout<<"NO"<<endl;}
    else
    {
for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[2*N];

ll v[2*N][2];

void build(int node,int lb,int ub)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2);
        build(2*node+1,(lb+ub)/2 +1,ub);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
 //   cout<<"called "<<endl;
    int p1,p2;
    if(i>ub || j<lb)
    {return -1;}

    if(i<=lb && j>=ub)
    {return b[node];}

    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
     p2=rmq(2*node+1,(lb+ub)/2 +1,ub,i,j);
    // cout<<p1<<" "<<p2<<endl;
    if(p1==-1)
    {return b[node]=p2;}

    if(p2==-1)
    {return b[node]=p1;}

    if(a[p1]<=a[p2])
    {return b[node]=p1;}
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {

        if(!v[a[i]][0])
        {
            v[a[i]][0]=i;
        }
}
for(int i=n;i>0;i--)
    {

        if(!v[a[i]][1])
        {
            v[a[i]][1]=i;
        }
}
   // cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if((v[i][0]!=0 || v[i][1]!=0))
        {
          if(v[i][0]!=v[i][1])
            {
                int mm=rmq(1,1,n,v[i][0],v[i][1]);
         // cout<<l<<" "<<v[i][y]<<endl;
           // cout<<i<<" "<<mm<<endl;
            if(a[mm]<i){ans=false;break;}
          }

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


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        v[a[i]].push_back(i);
    }
    //cout<<endl;

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            //cout<<(v[i][j]-v[i][j-1])<<endl;
            if((v[i][j]-v[i][j-1])!=1)
                {
                   for(int k=v[i][j-1];k<v[i][j];k++)
                   {
                       if(a[k]<a[i])
                       {
                            ans=false;break;
                       }
                   }
                   }
    }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
    if(nz==n)
       {
           cout<<"YES"<<endl;
           for(int i=1;i<=n;i++)
           {
               cout<<q<<" ";
           }
           cout<<endl;
       }
    else if(!p && nz==0)
    {cout<<"NO"<<endl;}
    else
    {

       int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else if(pre!=-1){a[i]=pre;}
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[N];

vector<int> v[2*N];

void build(int node,int lb,int ub,int n)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2,n);
        build(2*node+1,(lb+ub)/2 +1,ub,n);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
    int p1,p2;
    if(i>ub || j<lb)
    {
        return -1;
    }
    if(i>=lb && j<=ub)
    {
        return b[node];
    }
    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
    p2=rmq(2*node+1,(lb+ub)/2,ub,i,j);
    if(p1==-1)
    {
        return b[node]=p2;
    }
    if(p2==-1)
    {
        return b[node]=p1;
    }
    if(a[p1]<=a[p2])
    {
        return b[node]=p1;
    }
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {

        v[a[i]].push_back(i);

    }

    for(int i=1;i<=q;i++)
    {
        if(!v[i].empty())
        {
            int y=(v[i].size()-1),l=v[i][0];
          if(v[i][y]!=l){  int mm=rmq(1,1,n,l,v[i][y]);
            //cout<<i<<" "<<a[mm]<<endl;
            if(a[mm]<i){ans=false;break;}
          }
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
        v[a[i]].push_back(i);
    }
    cout<<endl;

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            //cout<<(v[i][j]-v[i][j-1])<<endl;
            if((v[i][j]-v[i][j-1])!=1)
                {
                   for(int k=v[i][j-1];k<v[i][j];k++)
                   {
                       if(a[k]<a[i])
                       {
                            ans=false;break;
                       }
                   }
                   }
    }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        int p=v[a[i]].size();
        if(p>0)
            {
                if((v[a[i]][p-1]+1)!=i)
                    {
                        for(int j=(v[a[i]][p-1]+1);j<i;j++)
                        {
                            if(a[j]<a[i]){ans=false;break;}
                        }
                        if(!ans){break;}
                     }
               }
        v[a[i]].push_back(i);

    }
    //cout<<endl;
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[N];

vector<int> v[2*N];

void build(int node,int lb,int ub,int n)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2,n);
        build(2*node+1,(lb+ub)/2 +1,ub,n);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
    int p1,p2;
    if(i>ub || j<lb)
    {
        return -1;
    }
    if(i>=lb && j<=ub)
    {
        return b[node];
    }
    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
    p2=rmq(2*node+1,(lb+ub)/2,ub,i,j);
    if(p1==-1)
    {
        return b[node]=p2;
    }
    if(p2==-1)
    {
        return b[node]=p1;
    }
    if(a[p1]<=a[p2])
    {
        return b[node]=p1;
    }
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    /*    int p=v[a[i]].size();
    if(p>0)
            {
                if((v[a[i]][p-1]+1)!=i)
                    {
                        for(int j=(v[a[i]][p-1]+1);j<i;j++)
                        {
                            if(a[j]<a[i]){ans=false;break;}
                        }
                        if(!ans){break;}
                     }
               }
            */
        v[a[i]].push_back(i);

    }
    cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(!v[i].empty())
        {
            int y=(v[i].size()-1),l=v[i][0];
          if(v[i][y]!=l){  int mm=rmq(1,1,n,l,v[i][y]);
            //cout<<i<<" "<<a[mm]<<endl;
            if(a[mm]<i){ans=false;break;}
          }
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[2*N];

vector<int> v[2*N];

void build(int node,int lb,int ub,int n)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2,n);
        build(2*node+1,(lb+ub)/2 +1,ub,n);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
 //   cout<<"called "<<endl;
    int p1,p2;
    if(i>ub || j<lb)
    {return -1;}

    if(i<=lb && j>=ub)
    {return b[node];}

    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
     p2=rmq(2*node+1,(lb+ub)/2 +1,ub,i,j);
    // cout<<p1<<" "<<p2<<endl;
    if(p1==-1)
    {return b[node]=p2;}

    if(p2==-1)
    {return b[node]=p1;}

    if(a[p1]<=a[p2])
    {return b[node]=p1;}
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
    /*    int p=v[a[i]].size();
    if(p>0)
            {
                if((v[a[i]][p-1]+1)!=i)
                    {
                        for(int j=(v[a[i]][p-1]+1);j<i;j++)
                        {
                            if(a[j]<a[i]){ans=false;break;}
                        }
                        if(!ans){break;}
                     }
               }
            */
        v[a[i]].push_back(i);

    }
   // cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(!v[i].empty())
        {
            int y=(v[i].size()-1),l=v[i][0];
          if(v[i][y]!=l){  int mm=rmq(1,1,n,l,v[i][y]);
         // cout<<l<<" "<<v[i][y]<<endl;
           // cout<<i<<" "<<mm<<endl;
            if(a[mm]<i){ans=false;break;}
          }
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
    if(nz==n)
       {
           cout<<"YES"<<endl;
           for(int i=1;i<=n;i++)
           {
               cout<<q<<" ";
           }
           cout<<endl;
       }
    else if(!p && nz==0)
    {cout<<"NO"<<endl;}
    else
    {

       int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else
        {
            if(!p){a[i]=q;p=true;pre=q;}
            if(pre!=-1){a[i]=pre;}
    }
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
}

 int pre=-1;
          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && v[0].size()!=n)
{
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        v[a[i]].push_back(i);
    }

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            if((v[i][j]-v[i][j-1])!=1)ans=false;break;
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;
          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        v[a[i]].push_back(i);
    }

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            if((v[i][j]-v[i][j-1])!=1)ans=false;break;
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    v[a[i]].push_back(i);
}
if(!qp && v[0].size()!=n)
{
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            if((v[i][j]-v[i][j-1])!=1)ans=false;break;
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {
          int pre=-1;
          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[N];

vector<int> v[2*N];

void build(int node,int lb,int ub,int n)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2,n);
        build(2*node+1,(lb+ub)/2 +1,ub,n);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
 //   cout<<"called "<<endl;
    int p1,p2;
    if(i>ub || j<lb)
    {return -1;}

    if(i<=lb && j>=ub)
    {return b[node];}

    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
     p2=rmq(2*node+1,(lb+ub)/2 +1,ub,i,j);
    // cout<<p1<<" "<<p2<<endl;
    if(p1==-1)
    {return b[node]=p2;}

    if(p2==-1)
    {return b[node]=p1;}

    if(a[p1]<=a[p2])
    {return b[node]=p1;}
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
    /*    int p=v[a[i]].size();
    if(p>0)
            {
                if((v[a[i]][p-1]+1)!=i)
                    {
                        for(int j=(v[a[i]][p-1]+1);j<i;j++)
                        {
                            if(a[j]<a[i]){ans=false;break;}
                        }
                        if(!ans){break;}
                     }
               }
            */
        v[a[i]].push_back(i);

    }
   // cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(!v[i].empty())
        {
            int y=(v[i].size()-1),l=v[i][0];
          if(v[i][y]!=l){  int mm=rmq(1,1,n,l,v[i][y]);
         // cout<<l<<" "<<v[i][y]<<endl;
           // cout<<i<<" "<<mm<<endl;
            if(a[mm]<i){ans=false;break;}
          }
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        int p=v[a[i]].size();
        if(p>0)
            {
                if((v[a[i]][p-1]+1)!=i)
                    {

                      ans=false;break;
                }
               }
        v[a[i]].push_back(i);

    }
    //cout<<endl;
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
   else
      {
      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        v[a[i]].push_back(i);
    }

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            if((v[i][j]-v[i][j-1])!=1)ans=false;break;
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
    if(nz==n)
       {
           cout<<"YES"<<endl;
           for(int i=1;i<=n;i++)
           {
               cout<<q<<" ";
           }
           cout<<endl;
       }
    else if(!p)
    cout<<"NO"<<endl;
    else
    {

       int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else if(pre!=-1){a[i]=pre;}
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[4*N];

ll v[2*N][2];

void build(int node,int lb,int ub)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2);
        build(2*node+1,(lb+ub)/2 +1,ub);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
 //   cout<<"called "<<endl;
    int p1,p2;
    if(i>ub || j<lb)
    {return -1;}

    if(i<=lb && j>=ub)
    {return b[node];}

    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
     p2=rmq(2*node+1,(lb+ub)/2 +1,ub,i,j);
    // cout<<p1<<" "<<p2<<endl;
    if(p1==-1)
    {return b[node]=p2;}

    if(p2==-1)
    {return b[node]=p1;}

    if(a[p1]<=a[p2])
    {return b[node]=p1;}
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {

        if(!v[a[i]][0])
        {
            v[a[i]][0]=i;
        }
}
for(int i=n;i>0;i--)
    {

        if(!v[a[i]][1])
        {
            v[a[i]][1]=i;
        }
}
   // cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if((v[i][0]!=0 || v[i][1]!=0))
        {
          if(v[i][0]!=v[i][1])
            {
                int mm=rmq(1,1,n,v[i][0],v[i][1]);
         // cout<<l<<" "<<v[i][y]<<endl;
           // cout<<i<<" "<<mm<<endl;
            if(a[mm]<i){ans=false;break;}
          }

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


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        v[a[i]].push_back(i);
    }
    //cout<<endl;

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            //cout<<(v[i][j]-v[i][j-1])<<endl;
            if((v[i][j]-v[i][j-1])!=1)
                {
                   for(int k=v[i][j-1];k<v[i][j];k++)
                   {
                       if(a[k]<i)
                       {
                            ans=false;break;
                       }
                   }
                   }
    }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N],b[8*N];

ll v[2*N][2];

void build(int node,int lb,int ub)
{
    if(ub==lb)
    {
        b[node]=lb;
    }
    else
    {
        build(2*node,lb,(lb+ub)/2);
        build(2*node+1,(lb+ub)/2 +1,ub);
        if(a[b[2*node]]<=a[b[2*node +1]])
        {
            b[node]=b[2*node];
        }
        else
        {
            b[node]=b[2*node+1];
        }
    }
}

int rmq(int node,int lb,int ub,int i,int j)
{
 //   cout<<"called "<<endl;
    int p1,p2;
    if(i>ub || j<lb)
    {return -1;}

    if(i<=lb && j>=ub)
    {return b[node];}

    p1=rmq(2*node,lb,(lb+ub)/2,i,j);
     p2=rmq(2*node+1,(lb+ub)/2 +1,ub,i,j);
    // cout<<p1<<" "<<p2<<endl;
    if(p1==-1)
    {return b[node]=p2;}

    if(p2==-1)
    {return b[node]=p1;}

    if(a[p1]<=a[p2])
    {return b[node]=p1;}
    return b[node]=p2;
}

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

ll n,q,x=0;
cin>>n>>q;

bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

build(1,1,n);
if(!qp && x!=n)
{
    //cout<<"kjjk"<<endl;
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {

        if(!v[a[i]][0])
        {
            v[a[i]][0]=i;
        }
}
for(int i=n;i>0;i--)
    {

        if(!v[a[i]][1])
        {
            v[a[i]][1]=i;
        }
}
   // cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if((v[i][0]!=0 || v[i][1]!=0))
        {
          if(v[i][0]!=v[i][1])
            {
                int mm=rmq(1,1,n,v[i][0],v[i][1]);
         // cout<<l<<" "<<v[i][y]<<endl;
           // cout<<i<<" "<<mm<<endl;
            if(a[mm]<i){ans=false;break;}
          }

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


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
    if(nz==n)
       {
           cout<<"YES"<<endl;
           for(int i=1;i<=n;i++)
           {
               cout<<q<<" ";
           }
           cout<<endl;
       }
    else if(!q)
    cout<<"NO"<<endl;
    else
    {

       int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else if(pre!=-1){a[i]=pre;}
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll a[2*N];
vector<ll> v[2*N];

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

ll n,q,x=0;
cin>>n>>q;
bool qp=false,ans=true;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]==q){qp=true;}
    if(a[i]==0)x+=1;
}

 int pre=-1;

          for(int i=1;i<=n;i++)
          {
              if(a[i]!=0)pre=a[i];
              else
              {
                  if(!qp){a[i]=q;qp=true;pre=q;}
                 else if(pre!=-1)
                  {
                      a[i]=pre;
                  }
              }
          }
          int post=-1;
          for(int i=n;i>0;i--)
          {
              if(a[i]!=0)post=a[i];
              else
              {
                  if(post!=-1)
                  {
                      a[i]=post;
                  }
              }
          }

if(!qp && x!=n)
{
    cout<<"NO"<<endl;
}
else
{
    for(int i=1;i<=n;i++)
    {
        v[a[i]].push_back(i);
    }

    for(int i=1;i<=2*N;i++)
    {
        for(int j=1;j<v[i].size();j++)
        {
            if(abs(v[i][j]-v[i][j-1])!=1){ans=false;break;}
        }
    }
    if(!ans)
    {
        cout<<"NO"<<endl;
    }
    else
    {
      if(v[0].size()==n)
        {
           // memset(a,q,n+1);
    cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<q<<" ";
      }
      cout<<endl;
}
else
      {

      cout<<"YES"<<endl;
      for(int i=1;i<=n;i++)
      {
          cout<<a[i]<<" ";
      }
      cout<<endl;
    }
}
}

return 0;
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int a[2*N],b[8*N];
int c[2][N];

void build(int node,int l,int r)
{
    if(l==r){ b[node]=a[l];return;}
    int mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    if(b[2*node]<=b[2*node+1]){b[node]=b[2*node];}
    else {b[node]=b[2*node+1];}
    return ;
}
int rmq(int node,int l,int r,int i,int j)
{
    if(i>r || j<l){return -1;}
        if(l>=i && r<=j){return b[node];}
    int p1,p2;
    int mid=(l+r)/2;
    p1=rmq(2*node,l,mid,i,j);
    p2=rmq(2*node+1,mid+1,r,i,j);
    if(p1==-1)return p2;
   else if(p2==-1) return p1;
   else
   {
       return (p1<p2? p1:p2);
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,q,nz=0;
    cin>>n>>q;
    bool p=false, ans=true;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==q)p=true;
        if(a[i]==0)nz+=1;
    }
    if(nz==n)
       {
           cout<<"YES"<<endl;
           for(int i=1;i<=n;i++)
           {
               cout<<q<<" ";
           }
           cout<<endl;
       }
    else if(p)
    {cout<<"NO"<<endl;}
    else
    {

       int pre=-1,post=-1;

for(int i=1;i<=n;i++)
    {
        if(a[i]!=0){pre=a[i];}
        else if(pre!=-1){a[i]=pre;}
    }
    for(int i=n;i>0;i--)
    {
        if(a[i]!=0)post=a[i];
        else
        {
            if(post!=-1)a[i]=post;
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<a[i]<<" ";
        if(c[0][a[i]]==0)c[0][a[i]]=i;
    }
    //cout<<endl;
    for(int i=n;i>0;i--)
    {
        if(c[1][a[i]]==0)c[1][a[i]]=i;
    }
     build(1,1,n);
//for(int i=1;i<=2*n;i++)
//{
   // cout<<b[i]<<" ";
//}
//cout<<endl;
    for(int i=1;i<=q;i++)
    {
        if(c[0][i]!=c[1][i])
        {
            //cout<<c[0][i]<<" "<<c[1][i]<<endl;
            int mm=rmq(1,1,n,c[0][i],c[1][i]);
          //  cout<<mm<<" "<<i<<endl;
            if(mm<i)ans=0;
        }
    }
    if(ans)
    {cout<<"YES"<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    }
    else cout<<"NO"<<endl;

    }
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({+1, i});
            queries[R[i]+1].pb({-1, i});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        bool chk=false;
        for(auto aa:queries[i])
        {
            if(aa.x==-1)s.erase(aa.y);
            else
            {
                if(!chk)
                {
                    chk=true;
                    if(arr[i]!=0 && sz(s) && *s.rbegin() > arr[i])return cout<<"NO\n", 0;
                }
                s.insert(aa.y);
            }
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

    for(int i=1; i<=n; i++)
    {
        if(arr[i]==0)
        {
            int a=arr[i-1], j=i, b;
            while(arr[j+1]==0 && j<n)++j;
            b=arr[j+1];
            a=max(a, b);
            for(int k=i; k<=j; ++k)arr[k]=a;
            i=j;
        }
    }

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)
                {
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.x);
            }
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    bool chk=false;
    if(L[q]==0)
    for(int i=1; i<=n; i++)
    {
        if(was[i]==0)
        {
            chk=true;
            arr[i]=q;
            break;
        }
    }
    if(L[q]==0 && !chk)return cout<<"NO\n", 0;

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

    chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    for(int i=1; i<=n; i++)
        if(arr[i]==0)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(i==1)
        {
            queries[1].pb({1, +1});
            queries[n+1].pb({1, -1});
        }
        else if(L[i]!=0)
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)
                {
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.x);
            }
        }
        arr[i]=*s.rbegin();
    }
    bool chk=false;
    if(L[q]==0)
    for(int i=1; i<=n; i++)
    {
        if(was[i]==0)
        {
            chk=true;
            arr[i]=q;
            break;
        }
    }
    if(L[q]==0 && !chk)return cout<<"NO\n", 0;

    chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({+1, i});
            queries[R[i]+1].pb({-1, i});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        bool chk=false;
        for(auto aa:queries[i])
        {
            if(aa.x==-1)s.erase(aa.y);
            else
            {
                if(!chk)
                {
                    chk=true;
                    if(arr[i]!=0 && sz(s) && *s.rbegin() > arr[i])return cout<<"NO\n", 0;
                }
                s.insert(aa.y);
            }
        }
        if(!chk && arr[i]!=0 && sz(s) && *s.rbegin() > arr[i])return cout<<"NO\n", 0;
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

    for(int i=1; i<=n; i++)
    {
        if(arr[i]==0)
        {
            int a=arr[i-1], j=i, b;
            while(arr[j+1]==0 && j<n)++j;
            b=arr[j+1];
            a=max(a, b);
            for(int k=i; k<=j; ++k)arr[k]=a;
            i=j;
        }
    }

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({+1, i});
            queries[R[i]+1].pb({-1, i});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        if(arr[i]!=0 && sz(s) && *s.rbegin() > arr[i])return cout<<"NO\n", 0;
        for(auto aa:queries[i])
        {
            if(aa.x==-1)s.erase(aa.y);
            else s.insert(aa.y);
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

    for(int i=1; i<=n; i++)
    {
        if(arr[i]==0)
        {
            int a=arr[i-1], j=i, b;
            while(arr[j+1]==0 && j<n)++j;
            b=arr[j+1];
            a=max(a, b);
            for(int k=i; k<=j; ++k)arr[k]=a;
            i=j;
        }
    }

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }
    for(int i=1; i<=q; i++)
    {
        if(i==1)
        {
            queries[1].pb({1, +1});
            queries[n+1].pb({1, -1});
        }
        else
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }
    for(int i=1; i<=n; i++)
        sort(all(queries[i]));
    set<int>s;
    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)return cout<<"NO\n", 0;
                s.insert(aa.x);
            }
        }
        arr[i]=*s.rbegin();
    }
    for(int i=q; i>=1; i--)
        if(L[i]==0)
        {
            for(int j=1; j<=n; j++)
                if(was[j]==0)
                {
                    arr[j]=i;
                    break;
                }
            break;
        }
    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(i==1)
        {
            queries[1].pb({1, +1});
            queries[n+1].pb({1, -1});
        }
        else if(L[i]!=0)
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)
                {
                    cout<<*s.rbegin()<<" "<<aa.x<<"\n";
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.x);
            }
        }
        arr[i]=*s.rbegin();
    }
    bool chk=false;
    if(L[q]==0)
    for(int i=1; i<=n; i++)
    {
        if(was[i]==0)
        {
            chk=true;
            arr[i]=q;
            break;
        }
    }
    if(L[q]==0 && !chk)return cout<<"NO\n", 0;

    chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }
    for(int i=1; i<=q; i++)
    {
        if(i==1)
        {
            queries[1].pb({1, +1});
            queries[n+1].pb({1, -1});
        }
        else
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }
    for(int i=1; i<=n; i++)
        sort(all(queries[i]));
    set<int>s;
    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)return cout<<"NO\n", 0;
                s.insert(aa.x);
            }
        }
        arr[i]=*s.rbegin();
    }
    int now=q;
    for(int j=1; j<=n; j++)
        if(was[j]==0)
        {
            while(now>=1 && L[now]!=0)now--;
            if(now>=1)
            {
                arr[j]=now;
                now--;
            }
        }

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)
                {
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.x);
            }
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

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

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    for(int i=1; i<=n; i++)
        if(arr[i]==0)
        {
            assert(0<-1);
            return cout<<"NO\n", 0;
        }

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];
vector<pii>queries[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }
    for(int i=1; i<=q; i++)
    {
        if(i==1)
        {
            queries[1].pb({1, +1});
            queries[n+1].pb({1, -1});
        }
        else
        {
            queries[L[i]].pb({i, +1});
            queries[R[i]+1].pb({i, -1});
        }
    }
    for(int i=1; i<=n; i++)
        sort(all(queries[i]));
    set<int>s;
    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.y==-1)s.erase(aa.x);
            else
            {
                if(sz(s) && *s.rbegin()>aa.x)return cout<<"NO\n", 0;
                s.insert(aa.x);
            }
        }
        arr[i]=*s.rbegin();
    }

    int now=q;
    for(int j=1; j<=n; j++)
        if(was[j]==0)
        {
            while(now>=1 && L[now]!=0)now--;
            if(now>=1)
            {
                arr[j]=now;
                now--;
            }
        }
    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;
    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({+1, i});
            queries[R[i]+1].pb({-1, i});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.x==-1)s.erase(aa.y);
            else
            {
                if(sz(s) && *s.rbegin()>aa.y)
                {
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.y);
            }
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

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

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, q, arr[maxn], L[maxn], R[maxn], was[maxn];

vector<pii>queries[maxn];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        was[i]=arr[i];
        if(L[arr[i]]==0)L[arr[i]]=i;
        R[arr[i]]=i;
    }

    for(int i=1; i<=q; i++)
    {
        if(L[i]!=0)
        {
            queries[L[i]].pb({+1, i});
            queries[R[i]+1].pb({-1, i});
        }
    }

    for(int i=1; i<=n; i++)
        sort(all(queries[i]));

    set<int>s;

    for(int i=1; i<=n; i++)
    {
        for(auto aa:queries[i])
        {
            if(aa.x==-1)s.erase(aa.y);
            else
            {
                if(sz(s) && *s.rbegin()>aa.y)
                {
                    return cout<<"NO\n", 0;
                }
                s.insert(aa.y);
            }
        }
        if(sz(s))arr[i]=*s.rbegin();
    }

    if(L[q]==0)
    {
        bool chk=false;
        for(int i=1; i<=n; i++)
        {
            if(was[i]==0)
            {
                chk=true;
                arr[i]=q;
                break;
            }
        }
        if(!chk)return cout<<"NO\n", 0;
    }

    for(int i=1; i<=n; i++)
    {
        if(arr[i]==0)
        {
            int a=arr[i-1], j=i, b;
            while(arr[j+1]==0 && j<n)++j;
            b=arr[j+1];
            a=max(a, b);
            for(int k=i; k<=j; ++k)arr[k]=a;
            i=j;
        }
    }

    bool chk=false;
    for(int i=1; i<=n; i++)if(arr[i]==q)chk=true;
    if(!chk)return cout<<"NO\n", 0;

    cout<<"YES\n";
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
    return 0;
}


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

const int N = 1e6 + 5;

int L[N], R[N], n, q, A[N];

set <int> S;

vector <int> pos[N];

bool pd(int i) {
	if(L[i] > R[i] || L[i - 1] > R[i - 1]) return 1;
	if(R[i] < L[i - 1] || R[i - 1] < L[i]) return 1;
	return (L[i] >= L[i - 1] && R[i] <= R[i - 1]);
}

void doit(int l, int r, int x) {
	if(l > r || !S.size()) return;
	set <int> :: iterator L = S.lower_bound(l);
	set <int> :: iterator R = S.upper_bound(r);
	if(R == S.begin()) return;
	-- R;
	if(L == S.end() || R == S.end()) return;
	if((*L) > (*R)) return;
	vector <int> cxt;
	cxt.clear();
	for(; L != R; ++ L) {
		A[*L] = x;
		cxt.push_back(*L);
	}
	A[*R] = x;
	cxt.push_back(*R);
	for(int i = 0; i < (int) cxt.size(); ++ i) S.erase(cxt[i]);
}

#define lowbit(x) (x & (-x))

int SS[N];

void add(int x, int v) {
	for(int i = x; i < N; i += lowbit(i)) SS[i] += v;
}

int sum(int x) {
	int res = 0;
	for(int i = x; i; i -= lowbit(i)) {
		res += SS[i];
	}
	return res;
}

bool pd(void) {
	for(int i = 0; i < (int) pos[0].size(); ++ i) add(pos[0][i], 1);
	for(int i = q; i >= 1; -- i) {
		for(int j = 0; j < (int) pos[i].size(); ++ j) add(pos[i][j], 1);
		if(R[i] < L[i]) continue;
		if(sum(R[i]) - sum(L[i] - 1) == R[i] - L[i] + 1) {
			continue;
		}
		return 1;
	}
	return 0;
}

queue <int> Q;

void BFS(void) {
	while(!Q.empty()) {
		int ind = Q.front();
		Q.pop();
		if(!A[ind - 1] && ind > 1) {
			A[ind - 1] = A[ind];
			Q.push(ind - 1);
		}
		if(ind < n && !A[ind + 1]) {
			Q.push(ind + 1);
			A[ind + 1] = A[ind];
		}
	}
}

main(void) {
	cin >> n >> q;
	memset(L, 127, sizeof(L));
	for(int i = 1; i <= n; ++ i) scanf("%d", &A[i]),
	L[A[i]] = min(L[A[i]], i), R[A[i]] = max(R[A[i]], i), pos[A[i]].push_back(i);
	if(pd()) {
		puts("NO");
		return 0;
	}
	for(int i = 1; i <= n; ++ i) {
		if(!A[i]) S.insert(i);
	}
	if(!S.size() && L[q] > R[q]) {
		puts("NO");
		return 0;
	}
	for(int i = q; i >= 1; -- i) {
		doit(L[i], R[i], i);
	}
	if(L[q] > R[q]) {
		bool ok = 0;
		for(int i = 1; i <= n; ++ i) if(!A[i]) {
			A[i] = q;
			ok = 1;
			break;
		}
		if(!ok) {
			//puts("NO");
			//return 0;
		}
	}
	for(int i = 1; i <= n; ++ i) {
		if(A[i])Q.push(i);
	}
	BFS();
	for(int i = 0; i <= q; ++ i) pos[i].clear();
	memset(SS, 0, sizeof(SS));
	memset(L, 127, sizeof(L));
	memset(R, 0, sizeof(R));
	for(int i = 1; i <= n; ++ i) pos[A[i]].push_back(i), L[A[i]] = min(L[A[i]], i), R[A[i]] = max(R[A[i]], i);
	if(pd()) {
		assert(0);
	}
	for(int i = 1; i <= n; ++ i) if(!A[i]) assert(0);
	puts("YES");
	for(int i = 1; i <= n; ++ i) printf("%d ", A[i]);
	puts("");
}