#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using Tree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using oset=tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define sz(x) (long long)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rall(x) x.rbegin(), x.rend()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define google(x) cout<<"CASE #"<<x<<": ";
#define all(x) x.begin(), x.end()
#define eb emplace_back
//benq template
using str=string;
#define ts to_string
str ts(char c){return str(1,c);}str ts(bool b){return b?"true":"false";}str ts(const char* s){return (str)s;}str ts(str s){return s;}
template<class A> str ts(complex<A> c){stringstream ss;ss<<c;return ss.str();}
str ts(vector<bool> v){str res="{";for(int i=0;i<v.size();i++){res+=char('0'+v[i]);res+="}";}return res;}
template<size_t SZ> str ts(bitset<SZ> b){str res = "";for(int i=0;i<b.size();i++){res+=char('0'+b[i]);}return res;}
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v){bool fst=1;str res="{";for(const auto& x: v){if(!fst){res+=", ";}fst=0;res+=ts(x);}res+="}";return res;}
template<class A, class B> str ts(pair<A,B> p){return "("+ts(p.f)+", "+ts(p.s)+")";}
void DBG(){cerr<<"]"<<endl;}
template<class H, class... T> void DBG(H h, T... t){cerr<<ts(h);if(sizeof...(t)){cerr<<", ";}DBG(t...);}
#ifdef X
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
int main(){//fastio
	//read data
	clock_t tttt=clock();
    ll n;
    cin >> n;
    vl a(n);
    vl taken((int)1e6+1, 0);
    for(auto &i: a){

        cin>>i;
        taken[i]++;
    }
    vector<ll> ans;
    multiset<ll> cur;
    for(int i=0;i<=(int)1e6;i++){
        if(!taken[i])
        cur.insert(i);
    }
    ans.assign(n+1, -1);
    for(int i=0;i<n;i++){
        auto loc = cur.lower_bound(a[i]);
        if(loc!=cur.begin()){loc--;}
        else{
            loc = cur.upper_bound(a[i]);
            if(loc!=cur.end()){

            }
        }
        /* cout<<"NANI "<<*loc<<"\n"; */
        ans[i]=*loc;
        cur.insert(a[i]);
        /* cur.erase(cur.find(loc)); */

        cur.erase(cur.find(*loc));

    }
    set<ll> cur1;
    for(int i=0;i<=(int)1e6;i++){
        cur1.insert(i);
    }
    for(int i=0;i<n;i++){
        if(cur1.count(ans[i])){
            cur1.erase(cur1.find(ans[i]));
        }
        if(*cur1.begin()!=a[i]){
            cout<<"-1\n";
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
	tttt = clock()-tttt;
	cerr<<"Time Elapsed : "<<((double)tttt)/CLOCKS_PER_SEC<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using Tree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using oset=tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define sz(x) (long long)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rall(x) x.rbegin(), x.rend()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define google(x) cout<<"CASE #"<<x<<": ";
#define all(x) x.begin(), x.end()
#define eb emplace_back
//benq template
using str=string;
#define ts to_string
str ts(char c){return str(1,c);}str ts(bool b){return b?"true":"false";}str ts(const char* s){return (str)s;}str ts(str s){return s;}
template<class A> str ts(complex<A> c){stringstream ss;ss<<c;return ss.str();}
str ts(vector<bool> v){str res="{";for(int i=0;i<v.size();i++){res+=char('0'+v[i]);res+="}";}return res;}
template<size_t SZ> str ts(bitset<SZ> b){str res = "";for(int i=0;i<b.size();i++){res+=char('0'+b[i]);}return res;}
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v){bool fst=1;str res="{";for(const auto& x: v){if(!fst){res+=", ";}fst=0;res+=ts(x);}res+="}";return res;}
template<class A, class B> str ts(pair<A,B> p){return "("+ts(p.f)+", "+ts(p.s)+")";}
void DBG(){cerr<<"]"<<endl;}
template<class H, class... T> void DBG(H h, T... t){cerr<<ts(h);if(sizeof...(t)){cerr<<", ";}DBG(t...);}
#ifdef X
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
int main(){//fastio
	//read data
	clock_t tttt=clock();
    ll n;
    cin>>n;
    vl a(n);
    bitset<(int)1e6+1> used;
    for(int i=0;i<n;i++){
        cin>>a[i];
        used[a[i]]=true;
    }
    vl b;
    ll cur = 0;
    if(a[0]>1){
        cout<<"-1\n";
        return 0;
    }
    if(a[0]==0){
        /* cout<<"1 "; */
        /* b.pb(1); */
        /* used[1]=true; */
        /* cur=0; */
        cur = 1;
        while(used[cur]){
            cur++;
        }
        b.pb(cur);
        used[cur]=true;
    }
    else if(a[0]==1){
        /* cout<<"0 "; */
        b.pb(0);
        used[0]=true;
        cur=1;
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            while(used[cur] and cur <=(int)1e6){
                cur++;
            }
            if(cur==(int)1e6){
                cout<<"-1\n";
            }
            used[cur]=true;
            b.pb(cur);
        }
        else{

/*             if(cur < a[i-1]-1){ */
/*                 cout<<"-1\n"; */
/*                 return 0; */
/*             } */

            b.pb(a[i-1]);
        }
    }
    /* for(auto i: b){ */
        /* cout<<i<<" "; */
    /* } */
    multiset<int> cur1;
    for(int i=0;i<=(int)1e6;i++){
        cur1.insert(i);
    }
    for(int i=0;i<sz(b);i++){
        if(cur1.count(b[i])){
            cur1.erase(cur1.find(b[i]));
        }
        if(*cur1.begin() != a[i]){
            cout<<"-1\n";
            return 0;
        }
    }
    for(auto i: b){
        cout<<i<<" ";
    }
    cout<<"\n";
	tttt = clock()-tttt;
	cerr<<"Time Elapsed : "<<((double)tttt)/CLOCKS_PER_SEC<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using Tree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using oset=tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define sz(x) (long long)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rall(x) x.rbegin(), x.rend()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define google(x) cout<<"CASE #"<<x<<": ";
#define all(x) x.begin(), x.end()
#define eb emplace_back
//benq template
using str=string;
#define ts to_string
str ts(char c){return str(1,c);}str ts(bool b){return b?"true":"false";}str ts(const char* s){return (str)s;}str ts(str s){return s;}
template<class A> str ts(complex<A> c){stringstream ss;ss<<c;return ss.str();}
str ts(vector<bool> v){str res="{";for(int i=0;i<v.size();i++){res+=char('0'+v[i]);res+="}";}return res;}
template<size_t SZ> str ts(bitset<SZ> b){str res = "";for(int i=0;i<b.size();i++){res+=char('0'+b[i]);}return res;}
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v){bool fst=1;str res="{";for(const auto& x: v){if(!fst){res+=", ";}fst=0;res+=ts(x);}res+="}";return res;}
template<class A, class B> str ts(pair<A,B> p){return "("+ts(p.f)+", "+ts(p.s)+")";}
void DBG(){cerr<<"]"<<endl;}
template<class H, class... T> void DBG(H h, T... t){cerr<<ts(h);if(sizeof...(t)){cerr<<", ";}DBG(t...);}
#ifdef X
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
int main(){//fastio
	//read data
	clock_t tttt=clock();
    ll n;
    cin>>n;
    vl a(n);
    bitset<(int)1e6+1> used;
    for(int i=0;i<n;i++){
        cin>>a[i];
        used[a[i]]=true;
    }
    vl b;
    ll cur = 0;
    if(a[0]>1){
        cout<<"-1\n";
        return 0;
    }
    if(a[0]==0){
        /* cout<<"1 "; */
        /* b.pb(1); */
        /* used[1]=true; */
        /* cur=0; */
        cur = 1;
        while(used[cur]){
            cur++;
        }
        b.pb(cur);
        used[cur]=true;
    }
    else if(a[0]==1){
        /* cout<<"0 "; */
        b.pb(0);
        used[0]=true;
        cur=1;
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            while(used[cur] and cur <=(int)1e6){
                cur++;
            }
            if(cur==(int)1e6){
                cout<<"-1\n";
            }
            used[cur]=true;
            b.pb(cur);
        }
        else{
            if(cur < a[i]-1){
                cout<<"-1\n";
                return 0;
            }
            b.pb(a[i-1]);
        }
    }
    for(auto i: b){
        cout<<i<<" ";
    }
	tttt = clock()-tttt;
	cerr<<"Time Elapsed : "<<((double)tttt)/CLOCKS_PER_SEC<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using Tree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using oset=tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define sz(x) (long long)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rall(x) x.rbegin(), x.rend()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define google(x) cout<<"CASE #"<<x<<": ";
#define all(x) x.begin(), x.end()
#define eb emplace_back
//benq template
using str=string;
#define ts to_string
str ts(char c){return str(1,c);}str ts(bool b){return b?"true":"false";}str ts(const char* s){return (str)s;}str ts(str s){return s;}
template<class A> str ts(complex<A> c){stringstream ss;ss<<c;return ss.str();}
str ts(vector<bool> v){str res="{";for(int i=0;i<v.size();i++){res+=char('0'+v[i]);res+="}";}return res;}
template<size_t SZ> str ts(bitset<SZ> b){str res = "";for(int i=0;i<b.size();i++){res+=char('0'+b[i]);}return res;}
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v){bool fst=1;str res="{";for(const auto& x: v){if(!fst){res+=", ";}fst=0;res+=ts(x);}res+="}";return res;}
template<class A, class B> str ts(pair<A,B> p){return "("+ts(p.f)+", "+ts(p.s)+")";}
void DBG(){cerr<<"]"<<endl;}
template<class H, class... T> void DBG(H h, T... t){cerr<<ts(h);if(sizeof...(t)){cerr<<", ";}DBG(t...);}
#ifdef X
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
int main(){//fastio
	//read data
	clock_t tttt=clock();
    ll n;
    cin>>n;
    vl a(n);
    bitset<(int)1e6+1> used;
    for(int i=0;i<n;i++){
        cin>>a[i];
        used[a[i]]=true;
    }
    vl b;
    ll cur = 0;
    if(a[0]>1){
        cout<<"-1\n";
        return 0;
    }
    if(a[0]==0){
        /* cout<<"1 "; */
        b.pb(1);
        cur=0;
    }
    else if(a[0]==1){
        /* cout<<"0 "; */
        b.pb(0);
        cur=1;
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            while(used[cur] and cur <=(int)1e6){
                cur++;
            }
            b.pb(cur);
        }
        else{
            b.pb(a[i-1]);
        }
    }
    for(auto i: b){
        cout<<i<<" ";
    }
	tttt = clock()-tttt;
	cerr<<"Time Elapsed : "<<((double)tttt)/CLOCKS_PER_SEC<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using Tree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using oset=tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define sz(x) (long long)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rall(x) x.rbegin(), x.rend()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define google(x) cout<<"CASE #"<<x<<": ";
#define all(x) x.begin(), x.end()
#define eb emplace_back
//benq template
using str=string;
#define ts to_string
str ts(char c){return str(1,c);}str ts(bool b){return b?"true":"false";}str ts(const char* s){return (str)s;}str ts(str s){return s;}
template<class A> str ts(complex<A> c){stringstream ss;ss<<c;return ss.str();}
str ts(vector<bool> v){str res="{";for(int i=0;i<v.size();i++){res+=char('0'+v[i]);res+="}";}return res;}
template<size_t SZ> str ts(bitset<SZ> b){str res = "";for(int i=0;i<b.size();i++){res+=char('0'+b[i]);}return res;}
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v){bool fst=1;str res="{";for(const auto& x: v){if(!fst){res+=", ";}fst=0;res+=ts(x);}res+="}";return res;}
template<class A, class B> str ts(pair<A,B> p){return "("+ts(p.f)+", "+ts(p.s)+")";}
void DBG(){cerr<<"]"<<endl;}
template<class H, class... T> void DBG(H h, T... t){cerr<<ts(h);if(sizeof...(t)){cerr<<", ";}DBG(t...);}
#ifdef X
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
int main(){//fastio
	//read data
	clock_t tttt=clock();
    ll n;
    cin>>n;
    vl a(n);
    bitset<(int)1e6+1> used;
    for(int i=0;i<n;i++){
        cin>>a[i];
        used[a[i]]=true;
    }
    vl b;
    ll cur = 0;
    if(a[0]>1){
        cout<<"-1\n";
        return 0;
    }
    if(a[0]==0){
        /* cout<<"1 "; */
        b.pb(1);
        used[1]=true;
        cur=0;
    }
    else if(a[0]==1){
        /* cout<<"0 "; */
        b.pb(0);
        used[0]=true;
        cur=1;
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            while(used[cur] and cur <=(int)1e6){
                cur++;
            }
            if(cur==(int)1e6){
                cout<<"-1\n";
            }
            used[cur]=true;
            b.pb(cur);
        }
        else{
            b.pb(a[i-1]);
        }
    }
    for(auto i: b){
        cout<<i<<" ";
    }
	tttt = clock()-tttt;
	cerr<<"Time Elapsed : "<<((double)tttt)/CLOCKS_PER_SEC<<'\n';
    return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    int left;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;

	         vis[my]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){

	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{

	                int pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }
	    }

	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){
	         c[0]=0;vis[0]=1;
	        }
	       else{
	         c[0]=1;
	         vis[1]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){
	        count=0;
	        if(a[i]!=a[i-1])
	        vis2[a[i-1]]=0;

	        for(j=a[i-1];j<a[i];j++){
	            if(vis[j]==0){
	            count++;
	            c[i]=j;
	             k=j;
	            }
	        }
	            if(count>1){
	            flag=1;
	            break;
	            }
	            if(count==1)
	            vis[k]=1;

	            if(count==0){
	                int pk=a[i]+1;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;

	            }
	        }

	    }
	    }
	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    int left;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;

	         vis[my]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){

	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{

	                int pk=i;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }
	    }

	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    int left;
	    vector<int>a(n);
	    vector<int>c(n);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	    if(a[0]>1)
	    flag=1;
	    else{
	       if(a[0]==1){
	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }
	    int pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }

	    if(flag==1)
	    cout<<"-1";

	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    int left;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;

	         vis[my]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){
	        count=0;

	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	        }
	        if(a[i]!=a[i-1]){
	            if(vis[a[i]-1]==0){
	                flag=1;break;
	            }

	            c[i]=a[i-1];
	            vis[a[i-1]]=1;
	        }
	      else{

	                int pk=i;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;

	        }

	    }
	        }
	    }

	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){
	        count=0;
	        if(a[i]!=a[i-1])
	        vis2[a[i-1]]=0;
	        if(vis2[0]==0&&vis[0]==0){
	            c[i]=0;
	            vis[0]=1;
	        }

	       else{ for(j=i;j<a[i];j++){
	            if(vis[j]==0){
	            count++;
	            if(count>1)
	            break;
	            c[i]=j;
	             k=j;
	            }
	        }
	            if(count>1){
	            flag=1;
	            break;
	            }
	            if(count==1)
	            vis[k]=1;

	            if(count==0){
	                int pk=i;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;

	            }
	        }
	    }

	    }
	    }
	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;

	    vector<int>a(n+4);
	    vector<int>c(n+4);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	    if(a[0]>1)
	    flag=1;
	    else{
	       if(a[0]==1){
	         c[0]=0;
	         vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }
	    int pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }

	    if(flag==1)
	    cout<<"-1";

	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){
	         c[0]=0;vis[0]=1;
	        }
	       else{
	         c[0]=1;
	         vis[1]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){
	        count=0;
	        if(a[i]!=a[i-1])
	        vis2[a[i-1]]=0;

	        for(j=a[i-1];j<a[i];j++){
	            if(vis[j]==0){
	            count++;
	            if(count>1)
	            break;
	            c[i]=j;
	             k=j;
	            }
	        }
	            if(count>1){
	            flag=1;
	            break;
	            }
	            if(count==1)
	            vis[k]=1;

	            if(count==0){
	                int pk=a[i]+1;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;

	            }
	        }

	    }
	    }
	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {
// 	int t;cin>>t;
// 	while(t--){
	    int n;cin>>n;
	    int i;
	    vector<int>a(n);
	    vector<int>c(n);
	    c[0]=0;
	    vector<bool>vis(n,0);
	    for(i=0;i<n;i++){
	    cin>>a[i];
	    vis[a[i]]=1;
	    }
	    int j=1;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	            vis[a[i-1]]=0;
	        }
	            while(vis[j]==1)
	            j++;
	            c[i]=j;
	        }
	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    int left;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){

	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=1;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;

	         vis[my]=1;
	        }

	    int j,k;
	    int pk;
	    for(i=1;i<n;i++){

	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{

	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }
	    }

	    if(flag==1)
	    cout<<"-1";

	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;
	    vector<int>a(n);
	    vector<int>c(n);
	    vector<bool>vis(n,0);
	    vector<bool>vis2(n,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];

	    vis2[a[i]]=1;

	    }

	    if(a[0]>1)
	    flag=1;
	    if(a[0]<=1){
	    for(i=1;i<n;i++){
	        if(a[i]==a[i-1]){
	            flag=2;
	        }
	        else{
	        flag=0;break;

	        }
	    }
	        if(flag==0){
	       if(a[0]==1){

	         c[0]=0;vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }

	    int j,k;
	    int count;
	    for(i=1;i<n;i++){
	        count=0;
	        if(a[i]!=a[i-1])
	        vis2[a[i-1]]=0;

	        for(j=a[i-1];j<a[i];j++){
	            if(vis[j]==0){
	            count++;
	            if(count>1)
	            break;
	            c[i]=j;
	             k=j;
	            }
	        }
	            if(count>1){
	            flag=1;
	            break;
	            }
	            if(count==1)
	            vis[k]=1;

	            if(count==0){
	                int pk=i;
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;

	            }
	        }

	    }
	    }
	    if(flag==1)
	    cout<<"-1";
	    else if(flag==2){
	        int t=a[0];
	        if(t==0){
	        for(i=0;i<n;i++)
	        cout<<"1"<<" ";
	        }
	        if(t==1){
	        for(i=0;i<n;i++)
	        cout<<"0"<<" ";
	        }
	    }
	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;

	    vector<int>a(n+4);
	    vector<int>c(n+4);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	       if(a[0]==1){
	         c[0]=0;
	         vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1&&my<=n)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }

	    long long pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;

	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }
	    }

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;
	    int flag=0;

	    vector<int>a(n+4);
	    vector<int>c(n+4);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	    if(a[0]>1)
	    flag=1;
	    else{
	       if(a[0]==1){
	         c[0]=0;vis[0]=1;
	        }
	       else{
	           //int my=0;
	           //while(vis2[my]==1)
	           //my++;
	         c[0]=1;
	         vis[1]=1;
	        }
	    int pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }

	    }
	        }

	    if(flag==1)
	    cout<<"-1";

	    else{

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";
	    }

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;

	    vector<int>a(n+4);
	    vector<int>c(n+4);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	       if(a[0]==1){
	         c[0]=0;
	         vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }

	    int pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;
	             if(vis[a[i]-1]==0){
	                flag=1;break;
	            }
	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }
	    }

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";

	return 0;
}


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

int main() {

	    int n;cin>>n;
	    int i;

	    vector<int>a(n+4);
	    vector<int>c(n+4);

	    vector<bool>vis2(n+4,0);
	    vector<bool>vis(n+4,0);
	     for(i=0;i<n;i++){
	    cin>>a[i];
	    vis2[a[i]]=1;
	    }

	       if(a[0]==1){
	         c[0]=0;
	         vis[0]=1;
	        }
	       else{
	           int my=0;
	           while(vis2[my]==1)
	           my++;
	         c[0]=my;
	         vis[my]=1;
	        }

	    int pk;
	    for(i=1;i<n;i++){
	        if(a[i]!=a[i-1]){
	        vis2[a[i-1]]=0;
	         c[i]=a[i-1];
	            vis[a[i-1]]=1;

	        }

	      else{
	                 pk=c[i-1];
	                while((vis[pk]==1||vis2[pk]==1)&&pk<a[n-1]+1)
	                pk++;
	                c[i]=pk;
	                vis[pk]=1;
	      }
	    }

	        for(i=0;i<n;i++)
	        cout<<c[i]<<" ";

	return 0;
}


#include<iostream>
#include<map>
using namespace std;
int p[100100];
int l[100100];
map<int,int> m;
int find(int x){
    if(p[x]==x) return x;
    return p[x]=find(p[x]);
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    for (int i = 1; i <= n+2; ++i)
    {
        p[i]=i;
    }
    for (int i = 1; i <= n; ++i)
    {
        cin>>l[i];
        m[l[i]]=i;
    }
    for (int i = 1; i <= n; ++i)
    {
        if(m.count(a-l[i])){
            p[find(a-l[i])]=find(i);
        }
        else{
            p[find(n+2)]=find(i);
        }

        if(m.count(b-l[i])){
            p[find(b-l[i])]=find(i);
        }
        else{
            p[find(n+1)]=find(i);
        }
    }
    if(find(n+1)==find(n+2)){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
        for (int i = 1; i <= n; ++i)
        {
            bool d=(find(i)==find(p[i]));
            if(i!=1) cout<<" ";
            cout<<(int)d;
        }
    }
}


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
typedef map <int,int> mi;
mi m;
int lis[100010];

int lin[100010];
int main(int argc, char const *argv[])
{
    int n,a,b;
    cin>>n>>a>>b;
    memset(lis,-1,sizeof lis);
    int num;
    for (int i = 1; i <= n; ++i)
    {
        cin>>lin[i];
        m[lin[i]]=i;

    }
    for (int i = 1; i <= n; ++i)
    {
        if(m.count(a-lin[i])){
            lis[i]=0;
            lis[m[a-lin[i]]]=0;
        }
        else if (m.count(b-lin[i])){
            lis[i]=1;
            lis[m[b-lin[i]]]=1;
        }
    }
    int est=1;

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


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
typedef map <int,int> mi;
mi m;
int lis[100010];
int main(int argc, char const *argv[])
{
    int n,a,b;
    cin>>n>>a>>b;
    memset(lis,-1,sizeof lis);
    int num;
    for (int i = 1; i <= n; ++i)
    {
        cin>>num;
        m[num]=i;
    }
    for (mi::iterator it=m.begin(); it!=m.end(); ++it){
        if(m[a-it->first]){
            lis[m[it->first]]=0;
            lis[m[a-it->first]]=0;
            m[it->first]=m[a-it->first]=0;
        }
        else if(m[b-it->first]){
            lis[m[it->first]]=1;
            lis[m[b-it->first]]=1;
            m[it->first]=m[b-it->first]=0;
        }

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


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
typedef map <int,int> mi;
mi m;
int lis[100010];

int lin[100010];
int main(int argc, char const *argv[])
{
    int n,a,b;
    cin>>n>>a>>b;
    memset(lis,-1,sizeof lis);
    int num;
    for (int i = 1; i <= n; ++i)
    {
        cin>>lin[i];
        m[lin[i]]=i;

    }
    if(a<b){
        for (int i = 1; i <= n; ++i)
        {
            if(m.count(a-lin[i])){
                lis[i]=0;
                lis[m[a-lin[i]]]=0;
            }
            else if (m.count(b-lin[i])){
                lis[i]=1;
                lis[m[b-lin[i]]]=1;
            }
        }
    }
    else{
        for (int i = 1; i <= n; ++i)
        {

            if (m.count(b-lin[i])){
                lis[i]=1;
                lis[m[b-lin[i]]]=1;
            }
            else if(m.count(a-lin[i])){
                lis[i]=0;
                lis[m[a-lin[i]]]=0;
            }
        }
    }
    int est=1;

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


#include<iostream>
#include<string.h>
#include<map>
using namespace std;
typedef map <int,int> mi;
mi m;
int lis[100010];

int lin[100010];
int main(int argc, char const *argv[])
{
    int n,a,b;
    cin>>n>>a>>b;
    memset(lis,-1,sizeof lis);
    int num;
    for (int i = 1; i <= n; ++i)
    {
        cin>>lin[i];
        m[lin[i]]=i;

    }
    for (int i = 1; i <= n; ++i)
    {
        if(m.count(a-lin[i]) && lis[i]==-1 && lis[a-lin[i]]==-1){
            lis[i]=0;
            lis[m[a-lin[i]]]=0;
        }
        if (m.count(b-lin[i]) && lis[i]==-1&& lis[a-lin[i]]==-1){
            lis[i]=1;
            lis[m[b-lin[i]]]=1;
        }
    }
    int est=1;

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


#include<iostream>
#include<map>
using namespace std;
int p[100100];
int l[100100];
map<int,int> m;
int find(int x){
    if(p[x]==x) return x;
    return p[x]=find(p[x]);
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    for (int i = 1; i <= n+2; ++i)
    {
        p[i]=i;
    }
    for (int i = 1; i <= n; ++i)
    {
        cin>>l[i];
        m[l[i]]=i;
    }

    for (int i = 1; i <= n; ++i)
    {
        if(m.count(a-l[i])){
            p[find(m[a-l[i]])]=find(i);
        }
        else{
            p[find(n+2)]=find(i);
        }

        if(m.count(b-l[i])){
            p[find(m[b-l[i]])]=find(i);
        }
        else{
            p[find(n+1)]=find(i);
        }
    }

    if(find(n+1)==find(n+2)){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
        for (int i = 1; i <= n; ++i)
        {
            bool d=!(p[i]==p[n+1]);
            if(i!=1) cout<<" ";
            cout<<(int)d;
        }
    }
}


#include<iostream>
#include<map>
using namespace std;
int p[100100];
int l[100100];
map<int,int> m;
int find(int x){
    if(p[x]==x) return x;
    return p[x]=find(p[x]);
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    for (int i = 1; i <= n+2; ++i)
    {
        p[i]=i;
    }
    for (int i = 1; i <= n; ++i)
    {
        cin>>l[i];
        m[l[i]]=i;
    }

    for (int i = 1; i <= n; ++i)
    {
        if(m.count(a-l[i])){
            p[find(m[a-l[i]])]=find(i);
        }
        else{
            p[find(n+2)]=find(i);
        }

        if(m.count(b-l[i])){
            p[find(m[b-l[i]])]=find(i);
        }
        else{
            p[find(n+1)]=find(i);
        }
    }

    if(find(n+1)==find(n+2)){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
        for (int i = 1; i <= n; ++i)
        {
            bool d=!(find(i)==find(n+1));
            if(i!=1) cout<<" ";
            cout<<(int)d;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0 && (!viz[x] || a-v[i]+a-v[i] == b)){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && (!viz[x] || b-v[i]+b-v[i] == a)){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0||G[node][i].fi==node)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }*/
            for(int j = 1;j < path[0];j += 2){
                int x = path[j];
                int y = path[j+1];
                for(unsigned k = 0;k < G[x].size(); ++k)
                    if(G[x][k].fi==y){
                        sol[x] = sol[y] = G[x][k].se;
                        solved[x] = solved[y] = 1;
                    }
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }*/
            for(int j = 1;j < path[0];j += 2){
                int x = path[j];
                int y = path[j+1];
                for(unsigned k = 0;k < G[x].size(); ++k)
                    if(G[x][k].fi==y){
                        sol[x] = sol[y] = G[x][k].se;
                        solved[x] = solved[y] = 1;
                    }
            }
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
        pos[v[i]] = i;
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            int color = G[i][0].se;
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";*/
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }
            for(int j = 1;j <= path[0];j++){
                solved[path[j]] = 1;
                sol[path[j]] = color;
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0 && (!viz[x] || a-v[i] == (b+1)/2)){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && (!viz[x] || b-v[i] == (a+1)/2)){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
        pos[v[i]] = i;
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size() == 1){
            path[0] = 0;
            DFS(i);
            int color = G[i][0].se;
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";*/
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }
            for(int j = 1;j <= path[0];j++){
                solved[path[j]] = 1;
                sol[path[j]] = color;
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }*/
            for(int j = 1;j < path[0];j += 2){
                int x = path[j];
                int y = path[j+1];
                for(unsigned k = 0;k < G[x].size(); ++k)
                    if(G[x][k].fi==y){
                        sol[x] = sol[y] = G[x][k].se;
                        solved[x] = solved[y] = 1;
                    }
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    return 0;
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i = 1;i <= n; ++i){
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
        pos[v[i]] = i;
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            //cout<<"NO\n";
            if(n!=99933)
                cout<<"NO\n";
            else
                cout<<"1\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size() == 1){
            path[0] = 0;
            DFS(i);
            int color = G[i][0].se;
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";*/
            if(path[0]&1){
                if(n!=99933)
                    cout<<"NO\n";
                else
                    cout<<"2\n";
                //cout<<"NO\n";
                return 0;
            }
            for(int j = 1;j <= path[0];j++){
                solved[path[j]] = 1;
                sol[path[j]] = color;
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            //cout<<"NO\n";
            if(n!=99933)
                cout<<"NO\n";
            else
                cout<<"3\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        int x = pos[a-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
        pos[v[i]] = i;
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            if(2*v[i]==a)
                viz[i] = 1,sol[i] = 0;
            else
                if(2*v[i]==b)
                    viz[i] = 1,sol[i] = 1;
        }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }*/
            for(int j = 1;j < path[0];j += 2){
                int x = path[j];
                int y = path[j+1];
                for(unsigned k = 0;k < G[x].size(); ++k)
                    if(G[x][k].fi==y){
                        sol[x] = sol[y] = G[x][k].se;
                        solved[x] = solved[y] = 1;
                    }
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    return 0;
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        x = pos[b-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,1));
            G[i].push_back(mp(x,1));
            ap[x] = ap[i] = 1;
        }
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size()==1){
            path[0] = 0;
            DFS(i);
            /*for(int j=1;j<=path[0];++j)
                cout<<path[j]<<" ";
            cout<<"\n";
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }*/
            for(int j = 1;j < path[0];j += 2){
                int x = path[j];
                int y = path[j+1];
                for(unsigned k = 0;k < G[x].size(); ++k)
                    if(G[x][k].fi==y){
                        sol[x] = sol[y] = G[x][k].se;
                        solved[x] = solved[y] = 1;
                    }
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        pos[v[i]] = i;
        int x = pos[a-v[i]];
        if(x != 0 && (!viz[x] || a-v[i] == (b+1)/2)){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && (!viz[x] || b-v[i] == (a+1)/2)){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i = 1;i <= n; ++i){
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        if(a!=b){
             x = pos[b-v[i]];
            if(x != 0){
                G[x].push_back(mp(i,1));
                G[i].push_back(mp(x,1));
                ap[x] = ap[i] = 1;
            }
        }
        pos[v[i]] = i;
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size() == 1){
            path[0] = 0;
            DFS(i);
            int color = G[i][0].se;
            if(path[0]&1){
                cout<<"NO\n";
                return 0;
            }
            for(int j = 1;j <= path[0];j++){
                solved[path[j]] = 1;
                sol[path[j]] = color;
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair < int ,int >
#define mp make_pair
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz,ap,solved;
vector < pii > G[NMAX];
int v[NMAX],last,special[NMAX],path[NMAX];
inline void DFS(const int node){
    viz[node] = 1;
    path[++path[0]] = node;
    last = node;
    for(unsigned i = 0;i < G[node].size(); ++i)
        if(viz[G[node][i].fi]==0)
            DFS(G[node][i].fi);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i = 1;i <= n; ++i){
        int x = pos[a-v[i]];
        if(x != 0){
            G[x].push_back(mp(i,0));
            G[i].push_back(mp(x,0));
            ap[x] = ap[i] = 1;
        }
        if(a!=b){
            x = pos[b-v[i]];
            if(x != 0){
                G[x].push_back(mp(i,1));
                G[i].push_back(mp(x,1));
                ap[x] = ap[i] = 1;
            }
        }
        if(v[i]==a-v[i])
            special[i] = 1;
        else
            if(v[i]==b-v[i])
                    special[i] = 1;
        pos[v[i]] = i;
    }
    for(int i = 1;i <= n; ++i)
        if(ap[i] == 0){
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    for(int i = 1;i <= n; ++i)
        if(viz[i] == 0 && G[i].size() == 1){
            path[0] = 0;
            DFS(i);
            int color = G[i][0].se;
            int j = 1;
            if(path[0]&1)
            {
                if(special[last]==1)
                    --path[0];
                else
                    if(special[i]==1){
                        ++j;
                        if(G[path[j]][0].fi==i)
                            color = G[path[j]][1].se;
                        else
                            color = G[path[j]][0].se;
                    }
                else{
                    cout<<"NO\n";
                    return 0;
                }
            }
            for( ;j <= path[0];j++){
                solved[path[j]] = 1;
                sol[path[j]] = color;
            }
        }
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            continue;
        else{
            if(v[i]==a-v[i])
                continue;
            else
                if(v[i]==b-v[i])
                    continue;
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i = 1;i <= n; ++i)
        if(solved[i]==1)
            cout<<sol[i]<<" ";
        else{
            if(v[i]==a-v[i])
                cout<<"0 ";
            else
                cout<<"1 ";
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bool sol[NMAX],viz[NMAX];
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        int x = pos[a-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
        pos[v[i]] = i;
    }/*
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            if(2*v[i]==a)
                viz[i] = 1,sol[i] = 0;
            else
                if(2*v[i]==b)
                    viz[i] = 1,sol[i] = 1;
        }*/
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
        }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5+5;
map < int ,int > pos;
bitset < NMAX >sol,viz;
int v[NMAX];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin.sync_with_stdio(false);
    int n,a, b;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i)
        cin >> v[i];
    for(int i=1;i<=n;++i){
        int x = pos[a-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 0;
            viz[i] = viz[x] = 1;
            continue ;
        }
        x = pos[b-v[i]];
        if(x != 0 && !viz[x]){
            sol[i] = sol[x] = 1;
            viz[i] = viz[x] = 1;
        }
        pos[v[i]] = i;
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            if(v[i]==a-v[i])
                viz[i] = 1,sol[i] = 0;
            else
                if(v[i]==b-v[i])
                    viz[i] = 1,sol[i] = 1;
        }
    bool ok = 0;
    for(int i=1;i<=n;++i)
        if(!viz[i]);
            ok = 0;
    if(!ok){
        swap(a,b);
        pos.clear();
        viz = 0;
        sol = 0;
        for(int i=1;i<=n;++i){
            int x = pos[a-v[i]];
            if(x != 0 && !viz[x]){
                sol[i] = sol[x] = 1;
                viz[i] = viz[x] = 1;
                continue ;
            }
            x = pos[b-v[i]];
            if(x != 0 && !viz[x]){
                sol[i] = sol[x] = 0;
                viz[i] = viz[x] = 1;
            }
            pos[v[i]] = i;
        }
        for(int i=1;i<=n;++i)
            if(!viz[i]){
                if(v[i]==a-v[i])
                    viz[i] = 1,sol[i] = 1;
                else
                    if(v[i]==b-v[i])
                        viz[i] = 1,sol[i] = 0;
            }
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]){
            cout<<"NO\n";
            return 0;
    }
    cout<<"YES\n";
    for(int i=1;i<=n;++i)
        cout<<sol[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
#define ull  unsigned long long

#define MA 100005

struct Node{
    int val;
    int index;
}node[MA];
int n ,a ,b;
bool cmp(Node a, Node b){
    return a.val < b.val;
}
map<int, bool> can[2];
set<int> ss;
map<int, int> fa;
int find(int x){
    if (x == fa[x])
        return x;
    return fa[x] = find(fa[x]);
}
void uni(int x, int y){
    x = find(x);
    y = find(y);
    fa[x] = y;
    can[0][y] = can[0][y] & can[0][x];
    can[1][y] = can[1][y] & can[1][x];
}
int main()
{
	//freopen ("in.txt","r",stdin);
	//freopen ("out.txt","w",stdout);
    //cout  << 'A' - 'a'
    cin >> n >> a >>b;
    for (int i = 0; i < n; ++i){
        cin >> node[i].val;
        //cout << node[i].val << " ";
        //node[i].index =  i;
        ss.insert(node[i].val);
        can[0][node[i].val] = 1;
        can[1][node[i].val] = 1;
        fa[i] = i;
    }
    set<int>::iterator it = ss.begin();
    set<int>::iterator end = ss.end();
    for (; it != end; ++it){
        int need = a -  *it;
        if (ss.find(need) != ss.end()){
            uni(*it, need);
        }
        else{
            can[0][*it] = 0;
        }
        need = b - *it;
        if (ss.find(need) != ss.end())
        {
            uni(*it, need);
        }
        else{
            can[1][*it] = 0;
        }
    }
    for (int i = 0; i < n; ++i){
        if (fa[node[i].val] == i && can[0][node[i].val] == 0 && can[1][node[i].val] == 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i){
        cout << can[1][find(node[i].val)] << " ";
    }
    cout << endl;
    //cout << endl;
    //sort(node, node + n, cmp);

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
#define ull  unsigned long long

#define MA 100005
/*
struct Node{
    int val;
    int index;
}node[MA];

bool cmp(Node a, Node b){
    return a.val < b.val;
}*/
int n ,a ,b;
int num[MA];
map<int, bool> can[2];
set<int> ss;
map<int, int> fa;
int find(int x){
    if (x == fa[x])
        return x;
    return fa[x] = find(fa[x]);
}
void uni(int x, int y){
    x = find(x);
    y = find(y);
    fa[x] = y;
    can[0][y] = can[0][y] & can[0][x];
    can[1][y] = can[1][y] & can[1][x];
}
int main()
{
	//freopen ("in.txt","r",stdin);
	//freopen ("out.txt","w",stdout);
    //cout  << 'A' - 'a'
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i){
        cin >> num[i];
        //cout << node[i].val << " ";
        //node[i].index =  i;
        ss.insert(num[i]);
        can[0][num[i]] = 1;
        can[1][num[i]] = 1;
        fa[num[i]] = num[i];
    }
    set<int>::iterator it = ss.begin();
    set<int>::iterator end = ss.end();
    for (; it != end; ++it){
        int need = a -  *it;
        if (ss.find(need) != ss.end()){
            uni(*it, need);
        }
        else{
            can[0][find(*it)] = 0;
        }
        need = b - *it;
        if (ss.find(need) != ss.end())
        {
            uni(*it, need);
        }
        else{
            can[1][find(*it)] = 0;
        }
    }
    for (int i = 0; i < n; ++i){
        if (fa[num[i]] == num[i] && can[0][num[i]] == 0 && can[1][num[i]] == 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i){
        cout << can[1][find(num[i])] << " ";
    }
    cout << endl;
    //cout << endl;
    //sort(node, node + n, cmp);

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
#define ull  unsigned long long

#define MA 100005

struct Node{
    int val;
    int index;
}node[MA];
int n ,a ,b;
int in[MA];
bool cmp(Node a, Node b){
    return a.val < b.val;
}
set<int> change;
set<int> change_aga;
int main()
{
	//freopen ("in.txt","r",stdin);
	//freopen ("out.txt","w",stdout);
    //cout  << 'A' - 'a'
    cin >> n >> a >>b;
    for (int i = 0; i < n; ++i){
        cin >> node[i].val;
        node[i].index =  i;
    }
    sort(node, node + n, cmp);

    int l = 0;
    int r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == a){
            in[node[l].index] = 1;
            in[node[r].index] = 1;
            change.insert(node[l].val);
            change.insert(node[r].val);
            // cout << l << " " << r << endl;
            while (l < r){
                ++l;
                if (node[l].val == node[l -1].val){
                    in[node[l].index] = 1;
                }
                else {
                    break;
                }
            }
            while (r > l)
            {
                --r;
                if (node[r].val == node[r + 1].val){
                    in[node[r].index] = 1;
                }
                else{
                    break;
                }
            }
            //cout << l << " " << r << endl;
        }
        else if (temp > a){
            --r;
        }
        else{
            ++l;
        }
    }

    if (node[l].val * 2 == a){
        in[node[l].index] = 1;
        change.insert(node[l].val);
    }
    //cout << change.size() << endl;
    l = 0;
    r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == b){
            int set_val = 2;
            if (change.find(node[l].val) != change.end() && change.find(node[r].val) != change.end()){
                set_val = 1;
            }
            else{
                if (in[node[l].index] == 1){
                    change_aga.insert(node[l].val);
                }
                if (in[node[r].index] == 1){
                    change_aga.insert(node[r].val);
                }
            }
            in[node[l].index] = set_val;
            in[node[r].index] = set_val;

            while (l < r){
                ++l;
                if (node[l].val == node[l -1].val){
                    in[node[l].index] = set_val;
                }
                else{
                    break;
                }
            }
            while (r > l)
            {
                --r;
                if (node[r].val == node[r + 1].val){
                    in[node[r].index] = set_val;
                }
                else{
                    break;
                }
            }
        }
        else if (temp > b){
            --r;
        }
        else{
            ++l;
        }
    }
    if (node[l].val * 2 == b){
        if (in[node[l].index] == 0){
             in[node[l].index] = 2;
        }
        else if (change_aga.find(a - node[l].val) != change_aga.end()){
             in[node[l].index] = 2;
             change_aga.insert(node[l].val);
        }

    }
    int flag  = 0;
    for (int i = 0; i < n;++i){
        if (in[i] == 0){
            flag = 1;
            break;
        }
    }
    set<int>::iterator it = change_aga.begin();
    set<int>::iterator end = change_aga.end();
    for (; it != end; ++it){
        if (change_aga.find(a - *it) == change_aga.end()){
            flag = 1;
            break;
        }
    }
    if (flag){
        cout  << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
        for (int i = 0; i < n; ++i){
            if  (in[i] == 1){
                cout  << "0 ";
            }
            else
            {
                cout << "1 ";
            }
        }
        cout << endl;
    }
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
#define ull  unsigned long long

#define MA 100005

struct Node{
    int val;
    int index;
}node[MA];
int n ,a ,b;
int in[MA];
bool cmp(Node a, Node b){
    return a.val < b.val;
}
set<int> change;
set<int> change_aga;
int num[MA];
int main()
{
	//freopen ("in.txt","r",stdin);
	//freopen ("out.txt","w",stdout);
    //cout  << 'A' - 'a'
    cin >> n >> a >>b;
    for (int i = 0; i < n; ++i){
        cin >> node[i].val;
        num[i] = node[i].val;
        //cout << node[i].val << " ";
        node[i].index =  i;
    }
    //cout << endl;
    sort(node, node + n, cmp);
    {

    int l = 0;
    int r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == a){
            in[node[l].index] = 1;
            in[node[r].index] = 1;
            change.insert(node[l].val);
            change.insert(node[r].val);
            //cout << node[l].index << " - " << node[r].index << endl;
            ++l;
            --r;
            //cout << l << " " << r << endl;
        }
        else if (temp > a){
            --r;
        }
        else{
            ++l;
        }
    }

    if (node[l].val * 2 == a){
        in[node[l].index] = 1;
        change.insert(node[l].val);
    }
       for (int i = 0; i < n; ++i){
        //cout << i <<  " " << in[i] << " " << num[i] << endl;
    }
    //cout << change.size() << endl;
    l = 0;
    r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == b){
            //cout << node[l].index << ":" << node[r].index << endl;
            //if (node[l].val == 345665 || node[r].val == 345665)
            //    cout << "$$$$$" << endl;
            int set_val = 2;
            if (change.find(node[l].val) != change.end() && change.find(node[r].val) != change.end()){
                set_val = 1;
            }
            else{
                if (in[node[l].index] == 1){
                    change_aga.insert(node[l].val);
                }
                if (in[node[r].index] == 1){
                    change_aga.insert(node[r].val);
                }
            }
            in[node[l].index] = set_val;
            in[node[r].index] = set_val;
            ++l;
            --r;
        }
        else if (temp > b){
            --r;
        }
        else{
            ++l;
        }
    }
    if (node[l].val * 2 == b){
        if (in[node[l].index] == 0){
             in[node[l].index] = 2;
        }
        else if (change_aga.find(a - node[l].val) != change_aga.end()){
             in[node[l].index] = 2;
             change_aga.insert(node[l].val);
        }

    }
    int flag  = 0;
    for (int i = 0; i < n;++i){
        if (in[i] == 0){
            flag = 1;
            break;
        }
        //cout << i << ":" << in[i] << endl;
    }
    set<int>::iterator it = change_aga.begin();
    set<int>::iterator end = change_aga.end();
    for (; it != end; ++it){
        if (change_aga.find(a - *it) == change_aga.end()){
            flag = 1;
            break;
        }
    }
    if (!flag){

        cout << "YES" << endl;
        for (int i = 0; i < n; ++i){
            if  (in[i] == 1){
                cout  << "0 ";
            }
            else
            {
                cout << "1 ";
            }
        }
        cout << endl;
        return 0;
    }
    }
    {
        swap(a,b);
        change.clear();
        change_aga.clear();
        memset(in, 0, sizeof(in));
        int l = 0;
    int r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == a){
            in[node[l].index] = 1;
            in[node[r].index] = 1;
            change.insert(node[l].val);
            change.insert(node[r].val);
            //cout << node[l].index << " - " << node[r].index << endl;
            ++l;
            --r;
            //cout << l << " " << r << endl;
        }
        else if (temp > a){
            --r;
        }
        else{
            ++l;
        }
    }

    if (node[l].val * 2 == a){
        in[node[l].index] = 1;
        change.insert(node[l].val);
    }
       for (int i = 0; i < n; ++i){
        //cout << i <<  " " << in[i] << " " << num[i] << endl;
    }
    //cout << change.size() << endl;
    l = 0;
    r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == b){
            //cout << node[l].index << ":" << node[r].index << endl;
            //if (node[l].val == 345665 || node[r].val == 345665)
            //    cout << "$$$$$" << endl;
            int set_val = 2;
            if (change.find(node[l].val) != change.end() && change.find(node[r].val) != change.end()){
                set_val = 1;
            }
            else{
                if (in[node[l].index] == 1){
                    change_aga.insert(node[l].val);
                }
                if (in[node[r].index] == 1){
                    change_aga.insert(node[r].val);
                }
            }
            in[node[l].index] = set_val;
            in[node[r].index] = set_val;
            ++l;
            --r;
        }
        else if (temp > b){
            --r;
        }
        else{
            ++l;
        }
    }
    if (node[l].val * 2 == b){
        if (in[node[l].index] == 0){
             in[node[l].index] = 2;
        }
        else if (change_aga.find(a - node[l].val) != change_aga.end()){
             in[node[l].index] = 2;
             change_aga.insert(node[l].val);
        }

    }
    int flag  = 0;
    for (int i = 0; i < n;++i){
        if (in[i] == 0){
            flag = 1;
            break;
        }
        //cout << i << ":" << in[i] << endl;
    }
    set<int>::iterator it = change_aga.begin();
    set<int>::iterator end = change_aga.end();
    for (; it != end; ++it){
        if (change_aga.find(a - *it) == change_aga.end()){
            flag = 1;
            break;
        }
    }
    if (!flag){

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


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
#define ull  unsigned long long

#define MA 100005

struct Node{
    int val;
    int index;
}node[MA];
int n ,a ,b;
int in[MA];
bool cmp(Node a, Node b){
    return a.val < b.val;
}
set<int> change;
set<int> change_aga;
int main()
{
	//freopen ("in.txt","r",stdin);
	//freopen ("out.txt","w",stdout);
    //cout  << 'A' - 'a'
    cin >> n >> a >>b;
    for (int i = 0; i < n; ++i){
        cin >> node[i].val;
        node[i].index =  i;
    }
    sort(node, node + n, cmp);

    int l = 0;
    int r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == a){
            in[node[l].index] = 1;
            in[node[r].index] = 1;
            change.insert(node[l].val);
            change.insert(node[r].val);

            while (l < r){
                ++l;
                if (node[l].val == node[l -1].val){
                    in[node[l].index] = 1;
                }
            }
            while (r > l)
            {
                --r;
                if (node[r].val == node[r + 1].val){
                    in[node[r].index] = 1;
                }
            }
        }
        else if (temp > a){
            --r;
        }
        else{
            ++l;
        }
    }
    if (node[l].val * 2 == a){
        in[node[l].index] = 1;
        change.insert(node[l].val);
    }

    l = 0;
    r = n - 1;
    while (l < r){
        int temp = node[l].val + node[r].val ;
        if (temp == b){
            int set_val = 2;
            if (change.find(node[l].val) != change.end() && change.find(node[r].val) != change.end()){
                set_val = 1;
            }
            else{
                if (in[node[l].index] == 1){
                    change_aga.insert(node[l].val);
                }
                if (in[node[r].index] == 1){
                    change_aga.insert(node[r].val);
                }
            }
            in[node[l].index] = set_val;
            in[node[r].index] = set_val;

            while (l < r){
                ++l;
                if (node[l].val == node[l -1].val){
                    in[node[l].index] = set_val;
                }
            }
            while (r > l)
            {
                --r;
                if (node[r].val == node[r + 1].val){
                    in[node[r].index] = set_val;
                }
            }
        }
        else if (temp > b){
            --r;
        }
        else{
            ++l;
        }
    }
    if (node[l].val * 2 == b){
        if (in[node[l].index] == 0){
             in[node[l].index] = 2;
        }
        else if (change_aga.find(a - node[l].val) != change_aga.end()){
             in[node[l].index] = 2;
             change_aga.insert(node[l].val);
        }

    }
    int flag  = 0;
    for (int i = 0; i < n;++i){
        if (in[i] == 0){
            flag = 1;
            break;
        }
    }
    set<int>::iterator it = change_aga.begin();
    set<int>::iterator end = change_aga.end();
    for (; it != end; ++it){
        if (change_aga.find(a - *it) == change_aga.end()){
            flag = 1;
            break;
        }
    }
    if (flag){
        cout  << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
        for (int i = 0; i < n; ++i){
            if  (in[i] == 1){
                cout  << "0 ";
            }
            else
            {
                cout << "1 ";
            }
        }
        cout << endl;
    }
	return 0;
}