#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#ifndef ONLINE_JUDGE
	#define ONLINE_JUDGE
#endif

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MOD(x) ((x)>0)?(x):(-(x))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,j,n) for(i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int> > graph;
const ll maxn = (ll) 1e5+9;
const ll mod = (ll) 1e9+7;
ll inf = (ll)1e12;
ll a[maxn],b[maxn];
ll dp[maxn];

int main()
{
	std::ios::sync_with_stdio(0);
	#ifndef ONLINE_JUDGE
		freopen("input.in","r",stdin);
	#endif
	ll i,j,k,t,q,m,l,r,n,md;
	cin>>n;
	repr(i,1,n)cin>>a[i]>>b[i];
	dp[1]=0;
	repr(i,1,n) {
		if((a[i]-b[i])>a[i-1])dp[i]=dp[i-1];
		else {
			k=a[i]-b[i];
			l=1,r=i-1;
			while(l<r) {
				md=(l+r)>>1;
				if(a[md]>=k)r=md;
				else if(a[md]<k)l=md+1;
			}
			dp[i]=dp[l-1]+(i-l);
			//cout<<i<<" "<<l<<endl;
		}
	}
	#ifndef ONLINE_JUDGE
		repr(i,1,n)cout<<a[i]<<" "<<b[i]<<endl;
	#endif

	//repr(i,1,n)cout<<dp[i]<<" ";cout<<endl;

	ll ans=inf;
	for(i=n;i>=0;i--) {
		ans = MIN(ans,dp[i]+(n-i));
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#ifndef ONLINE_JUDGE
	#define ONLINE_JUDGE
#endif

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MOD(x) ((x)>0)?(x):(-(x))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,j,n) for(i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int> > graph;
const ll maxn = (ll) 1e5+9;
const ll mod = (ll) 1e9+7;
ll inf = (ll)1e12;
ll a[maxn],b[maxn];
ll dp[maxn];

int main()
{
	std::ios::sync_with_stdio(0);
	#ifndef ONLINE_JUDGE
		freopen("input.in","r",stdin);
	#endif
	ll i,j,k,t,q,m,l,r,n,md;
	cin>>n;
	repr(i,1,n)cin>>a[i]>>b[i];
	dp[1]=0;
	repr(i,1,n) {
		if(MOD(b[i]-a[i])>a[i-1])dp[i]=dp[i-1];
		else {
			k=MOD(b[i]-a[i]);
			l=1,r=i-1;
			while(l<r) {
				md=(l+r)>>1;
				if(a[md]>=k)r=md;
				else if(a[md]<k)l=md+1;
			}
			dp[i]=dp[l-1]+(i-l);
			//cout<<i<<" "<<l<<endl;
		}
	}

	//repr(i,1,n)cout<<dp[i]<<" ";cout<<endl;

	ll ans=inf;
	for(i=n;i>=0;i--) {
		ans = MIN(ans,dp[i]+(n-i));
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define pii pair<int,int>

using namespace std;
vector<pii> vec;
int dp[1000009];
int main()
{
    int n,i,j,k,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        vec.pb(make_pair(a+1,b));
    }
    j=0;
    int ans=0;
    sort(vec.begin(),vec.end());
    for(i=1;i<1000009;i++){
        if(j<n && vec[j].first==i){
            a=max(0,i-vec[j].second -1);
            dp[i]=dp[a]+1;
            j++;
        }
        else dp[i]=dp[i-1];

        ans=max(ans,dp[i]);
    }
    printf("%d",n-ans);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define pii pair<int,int>

using namespace std;
vector<pii> vec;
int dp[1000009];
int main()
{
    int n,i,j,k,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        vec.pb(make_pair(a,b));
    }
    j=0;
    int ans=0;
    for(i=1;i<=1000000;i++){
        if(j<n && vec[j].first==i){
            a=max(0,i-vec[j].second -1);
            dp[i]=dp[a]+1;
            j++;
        }
        else dp[i]=dp[i-1];
        ans=max(ans,dp[i]);
    }
    printf("%d",n-ans);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define pii pair<int,int>

using namespace std;
vector<pii> vec;
int dp[1000009];
int main()
{
    int n,i,j,k,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        vec.pb(make_pair(a,b));
    }
    j=0;
    int ans=0;
    for(i=0;i<=1000000;i++){
        if(j<n && vec[j].first==i){
            a=max(0,i-vec[j].second -1);
            dp[i]=dp[a]+1;
            j++;
        }
        else{
            a=max(i-1,0);
            dp[i]=dp[a];
        }
        ans=max(ans,dp[i]);
    }
    printf("%d",n-ans);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define pii pair<int,int>

using namespace std;
vector<pii> vec;
int dp[1000009];
int main()
{
    int n,i,j,k,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        vec.pb(make_pair(a+1,b));
    }
    j=0;
    int ans=0;
    for(i=1;i<=1000009;i++){
        if(j<n && vec[j].first==i){
            a=max(0,i-vec[j].second -1);
            dp[i]=dp[a]+1;
            j++;
        }
        else dp[i]=dp[i-1];

        ans=max(ans,dp[i]);
    }
    printf("%d",n-ans);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define lli long long int
#define pb push_back
#define mod 1000000007
#define pii pair<int,int>

using namespace std;
vector<pii> vec;
int dp[1000009];
int main()
{
    int n,i,j,k,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        vec.pb(make_pair(a+1,b));
    }
    j=0;
    int ans=0;
    sort(vec.begin(),vec.end());
    for(i=1;i<=1000009;i++){
        if(j<n && vec[j].first==i){
            a=max(0,i-vec[j].second -1);
            dp[i]=dp[a]+1;
            j++;
        }
        else dp[i]=dp[i-1];

        ans=max(ans,dp[i]);
    }
    printf("%d",n-ans);

    return 0;
}


#include <iostream>

using namespace std;

int a[1000001],b[1000001];
int dp[1000001];
int pre1[1000001];

int main()
{
    int n;
    cin>>n;
    int ai,bi,ma=-1,mina = 9999999;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i] > ma)
            ma = a[i];
        if(a[i] < mina)
            mina = a[i];
        pre1[a[i]] = 1;
    }
    if(n == 1){
        cout<<"0\n";
        return 0;
    }
    int ans=-1;
    dp[mina] = 1;
    for(int i=mina+1;i<=ma;i++){
        if(pre1[i] == 1){
            dp[i] = b[i] >= i ? 1 : dp[i-b[i]-1] + 1;
        }else{
            dp[i] = dp[i-1];
        }
        if(dp[i] > ans)
            ans = dp[i];
    }
    cout<<n-ans<<"\n";
    return 0;
}


//In the Name of God
#include<iostream>
using namespace std;
const int N=3e6;
int n,A,a,i,p[N],c[N],b[N];
main()
{
  for(cin>>n;cin>>a>>b[a];c[a]+=1);
  for(i=0;i<=a;A=max(A,p[i++]))
    if(c[i]) if(b[i]>i) p[i]=1; else p[i]=p[i-b[i]-1]+1;
    else p[i]=p[i-1];
    cout<<n-A;
}


//In the Name of God
#include<iostream>
#include<vector>
#include<set>
#include<stack>
//#include<conio.h>

using namespace std;
long long n,b[1000001],d,ans,a,p[2000001];
int c[2000001];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
    cin>>a>>b[a];
    c[a]+=1;
    d=max(d,a);
    }
    for(int i=1;i<=d;i++)
    {
            if(c[i]==1)
            {
                       if(b[i]+1>i)
                       p[i]=1;
                       else
                       p[i]=p[i-b[i]-1]+1;
            }
            else
            p[i]=p[i-1];
            ans=max(ans,p[i]);
    }
    cout<<n-ans;
    //getch();
    return 0;
}


//In the Name of God
#include<iostream>
using namespace std;
const int N=3e6;
int n,A,a,i,p[N],c[N],b[N];
main()
{
  for(cin>>n;cin>>a>>b[a];c[a]+=1);
  for(i=0;i<=a;A=max(A,p[i++]))
    if(c[i]) if(b[i]+1>i) p[i]=1; else p[i]=p[i-b[i]-1]+1;
    else p[i]=p[i-1];
    cout<<n-A;
}


//God helps me.
#import<iostream>
using namespace std;
int n,A,d,i,b[1<<21];
main()
{
  for(cin>>n;cin>>i;cin>>b[i+1])d<i?d=i:1;
  for(i=1;i<d+2;A=max(A,b[i++]))b[i]=(b[i]?(b[(i-b[i]-1)*(b[i]+1<i)]+1):b[i-1]);
  cout<<n-A;
}


//In the Name of God
#include<iostream>
#include<vector>
#include<set>
#include<stack>
//#include<conio.h>

using namespace std;
long long n,b[1000001],d,ans,a,p[2000001];
int c[2000001];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
    cin>>a;
    cin>>b[a];
    c[a]+=1;
    d=max(d,a);
    }
    for(int i=0;i<=d;i++)
    {
            if(c[i]==1)
            {
                       if(b[i]+1>i)
                       p[i]=1;
                       else
                       p[i]=p[i-b[i]-1]+1;
            }
            else
            p[i]=p[i-1];
            ans=max(ans,p[i]);
    }
    cout<<n-ans;
    //getch();
    return 0;
}


//In the Name of God
#include<iostream>
#include<vector>
#include<set>
#include<stack>
//#include<conio.h>

using namespace std;
long long n,b[1000001],d,ans,a,p[2000001];
int c[2000001];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
    cin>>a;
    cin>>b[a];
    c[a]+=1;
    d=max(d,a);
    }
    for(int i=1;i<=d;i++)
    {
            if(c[i]==1)
            {
                       if(b[i]+1>i)
                       p[i]=1;
                       else
                       p[i]=p[i-b[i]-1]+1;
            }
            else
            p[i]=p[i-1];
            ans=max(ans,p[i]);
    }
    cout<<n-ans;
    //getch();
    return 0;
}


//In the Name of God
#include<iostream>

using namespace std;

int n,A,a,i,p[3e6],c[3e6],b[3e6];

main()
{
  for(cin>>n;cin>>a>>b[a];c[a]+=1);
  for(i=0;i<=a;A=max(A,p[i++]))
    if(c[i]) if(b[i]>i) p[i]=1; else p[i]=p[i-b[i]-1]+1;
    else p[i]=p[i-1];
    cout<<n-A;
}


//In the Name of God
#include<iostream>
using namespace std;
const int N=3e6;
int n,A,a,i,p[N],c[N],b[N];
main()
{
  for(cin>>n;cin>>a>>b[a];c[a]+=1);
  for(;i<=a;A=max(A,p[i]),i++)
    if(c[i]==1) if(b[i]+1>i) p[i]=1; else p[i]=p[i-b[i]-1]+1;
    else p[i]=p[i-1];
    cout<<n-A;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100005;
const int A = 1000006;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    return acc[v[i].pos-1] - acc[max(v[i].pos - v[i].pwr-1,0)];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100009;
const int A = 1000009;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100009;
const int A = 1000009;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    acc[0] = 0;
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = i;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100005;
const int A = 1000006;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(mid < 0) return 0;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100009;
const int A = 1000009;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    memset(acc,0,sizeof acc);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    acc[0] = 0;
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100005;
const int A = 1000006;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    return acc[v[i].pos-1] - acc[max(v[i].pos-v[i].pwr-1,0)];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100009;
const int A = 1000009;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    if(x < 0 || v[i].pos-1 < 0) exit(0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    acc[0] = 0;
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100005;
const int A = 1000006;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(lo >= 0)
            if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eps 1e-8
#define pii pair<int,int>
#define pll pair<long long,long long>
#define inf INT_MAX
#define ff first
#define ss second
using namespace std;
typedef long long ll;

//////////////0123456789
const int N = 100009;
const int A = 1000009;
const int modn = 1000000007;

struct bcn {
    int pos, pwr;
} v[N];

int acc[A+7];
int res[N];

bool comp (bcn a, bcn b){
    return a.pos < b.pos;
}

int explo(int i){
    int x = max(v[i].pos-v[i].pwr-1, 0);
    return acc[v[i].pos-1] - acc[x];
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&v[i].pos,&v[i].pwr);
        v[i].pos++;
        acc[v[i].pos]++;
    }
    sort(v,v+n,comp);
    acc[0] = 0;
    for(int i = 0; i < A; i++)
        acc[i+1] += acc[i];
    for(int i = 0; i < n; i++){
        res[i] = explo(i);
        int lo = 0, hi = v[i].pos-1;
        while(lo != hi){
            int mid = (lo+hi+1)/2;
            if(v[mid].pos < v[i].pos-v[i].pwr) lo = mid;
            else hi = mid-1;
        }
        if(v[lo].pos < v[i].pos - v[i].pwr) res[i] += res[lo];
    }
    int mini = INT_MAX;
    for(int i = 0; i < n; i++) mini = min(mini,n-i-1+res[i]);
    printf("%d\n",mini);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b;
    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
    }
    if (power[0]) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<=a; ++i) {
        if (!power[i]) {
            dp[i] = dp[i-1];
        }
        else {
            if (power[i] >= i) {
                dp[i] = 1;
            }
            else {
                dp[i] = dp[i-power[i]-1] + 1;
            }
        }
        ans = max(ans, dp[i]);
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b;
    scanf("%d", &n);
    for(int i=0; i<MAX; ++i) {
        power[i] = -1;
    }
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
    }
    if (power[0]!=-1) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<=a; ++i) {
        if (power[i]==-1) {
            dp[i] = dp[i-1];
        }
        else {
            dp[i] = dp[max(0, i-power[i]-1)] + 1;
        }
        ans = max(ans, dp[i]);
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b, up=-1;
    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
        up = max(up, a);
    }
    if (power[0]) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<=up; ++i) {
        if (power[i]==0) {
            dp[i] = dp[i-1];
        }
        else {
            if (power[i] >= i) {
                dp[i] = 1;
            }
            else {
                dp[i] = dp[i-power[i]-1] + 1;
            }
        }
        ans = max(ans, dp[i]);
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b;
    scanf("%d", &n);
    for(int i=0; i<MAX; ++i) {
        power[i] = -1;
    }
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
    }
    if (power[0]!=-1) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<=a; ++i) {
        if (power[i]==-1) {
            dp[i] = dp[i-1];
        }
        else {
            dp[i] = dp[max(0, i-power[i]-1)] + 1;
            ans = max(ans, dp[i]);
        }
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b;
    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
    }
    if (power[0]) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<MAX; ++i) {
        if (power[i]==0) {
            dp[i] = dp[i-1];
        }
        else {
            if (power[i] >= i) {
                dp[i] = 1;
            }
            else {
                dp[i] = dp[i-power[i]-1] + 1;
            }
        }
        ans = max(ans, dp[i]);
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


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

const int MAX = 1000006;

int power[MAX], dp[MAX];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("inp2.txt", "r", stdin);
    #endif
    int n, a, b;
    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        scanf("%d %d", &a, &b);
        power[a] = b;
    }
    if (!power[0]) {
        dp[0] = 1;
    }
    int ans = dp[0];
    for(int i=1; i<=a; ++i) {
        if (!power[i]) {
            dp[i] = dp[i-1];
        }
        else {
            if (power[i] >= i) {
                dp[i] = 1;
            }
            else {
                dp[i] = dp[i-power[i]-1] + 1;
            }
        }
        ans = max(ans, dp[i]);
    }
    ans = n - ans;
    printf("%d\n", ans);
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#define mem(a) memset(a,0,sizeof(a))
#define pfn printf("\n")
#define ll __int64
#define pfd(a) printf("%d\n",a)
#define pf2d(a,b) printf("%d %d\n",a,b)
#define pf3d(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfs(a) printf("%s\n",a)
#define sfd(a) scanf("%d",&a)
#define sf2d(a,b) scanf("%d%d",&a,&b)
#define sf3d(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sfs(a) scanf("%s",a)
#define sf  scanf
#define pf  printf
#define fr(i,n) for(int i=0;i<n;i++)
#define INF 0x7fffffff   //INT_MAX
#define inf 0x3f3f3f3f   //
const double PI = acos(-1.0);
const double e = exp(1.0);
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> inline T Min(T a, T b) { return a < b ? a : b; }
template<class T> inline T Max(T a, T b) { return a > b ? a : b; }
bool cmpbig(int a,int b){return a>b;}
bool cmpsmall(int a,int b){return a<b;}
using namespace std;
pair<int,int> p[1000005];
int dp[1000005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		scanf("%d %d",&p[i].first,&p[i].second);
	sort(p,p+n);
	int ans;
	for (int i=0;i<n;i++)
	{
		int pp=lower_bound(p,p+n,make_pair(p[i].first-p[i].second,-1))-p;
		dp[i]=dp[pp-1]+i-pp;
		ans=min(ans,n-i-1+dp[i]);
	}
	cout<<ans;
}


n = int(input())
array = list(map(int, input().split()))
array.sort()

if array[-1] >= array[0] + array[-2]:
    print("NO")
else:
    print("YES")
    for i in array:
        print(i, end=" ")


n = int(input())
nums = list(map(int, (input().split())))

def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''
    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False
    else: return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()

    while not circle_test(res):
        print('while')
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print(f'NO\n{res}')

    print('YES')
    print(*res)

main(nums)


# Version for Submission
n = int(input())
nums = list(map(int, (input().split())))

def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''

    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False

    else:
        return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    rem = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()
    res, rem, pos = start_circle(res)
    res = circle_next(res, rem, pos)

    while not circle_test(res):
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print('NO')
        break

    print('YES')
    print(*res)

main(nums)


n = int(input())
nums = list(map(int, (input().split())))

def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''
    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False
    else: return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()

    while not circle_test(res):
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print(f'NO')
        break

    print('YES')
    print(*res)

main(nums)


n = int(input())
nums = list(map(int, (input().split())))

# Version for Submission
def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''

    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False

    else:
        return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()
    res, rem, pos = start_circle(arr)
    res = circle_next(res, rem, pos)

    while not circle_test(res):
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print('NO')
        break

    print('YES')
    print(*res)

main(nums)


n = int(input())
nums = list(map(int, (input().split())))

# Version for Submission
def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''

    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False

    else:
        return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    rem = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()
    res, rem, pos = start_circle(res)
    res = circle_next(res, rem, pos)

    while not circle_test(res):
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print('NO')
        break

    print('YES')
    print(*res[:10])

main(nums)


n = int(input())
nums = list(map(int, (input().split())))

def is_impossible(arr):
    '''if max is larger than sum of next two largest numbers, circle is impossible'''
    arr.sort(reverse=True)
    if arr[0] >= arr[1] + arr[2]:
        return True
    else: return False

def circle_test(arr):
    '''checks whole array to see if it is circular per definition
    '''
    if arr[0] >= arr[1] + arr[-1]:
        return False

    for i in range(1, len(arr)-1):
        if arr[i] >= arr[i+1] + arr[i-1]:
            return False

    if arr[-1] >= arr[-2] + arr[0]:
        return False
    else: return True

def start_circle(arr):
    '''First step of making a circular array; largest element first, next largest second, third largest last'''
    res = []
    arr.sort(reverse=True)
    res = arr[:3]
    if len(arr) > 3:
        rem = arr[3:]
    pos = 2

    return res, rem, pos

def circle_next(res, rem, pos):
    ans = res[:2] + rem + res[-1:]
    return ans

def main(arr):

    # do pretest to see if it can't be circular
    if is_impossible(arr):
        print('NO')
        return

    res = arr.copy()

    while not circle_test(res):
        res, rem, pos = start_circle(arr)
        res = circle_next(res, rem, pos)
        print(f'NO')

    print('YES')
    print(*res)

main(nums)


#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)
def common(l1, l2):
    return set(l1).intersection(l2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          a=List()
          a.sort()
          b=[]
          c=[]
          for i in range(n):
               if(i%2==0):
                    b.append(a[i])
               else:
                    c.append(a[i])
          z=b+c
          if(a[-2]+a[-3]>a[-1]):
               print("YES")
               print(*z)
          else:
               print("NO")

#Call the solve function
if __name__ == "__main__":
     solution()


#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)
def common(l1, l2):
    return set(l1).intersection(l2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          a=List()
          a.sort()
          if(a[-2]+a[-3]>a[-1]):
               print("YES")
               print(*a[0:n-2],a[n-1],a[n-2])
          else:
               print("NO")

#Call the solve function
if __name__ == "__main__":
     solution()


#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)
def common(l1, l2):
    return set(l1).intersection(l2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          a=List()
          b=sorted(a)
          a.sort()
          f=a[0]
          l=a[-1]
          a.insert(0,l)
          a.append(f)
          c=0
          for i in range(1,len(a)-1):
               if(a[i]<a[i+1]+a[i-1]):
                    c+=1
               else:
                    print("NO")
                    c=0
                    break

          if(c>0):
               print("YES")
               print(*b)

#Call the solve function
if __name__ == "__main__":
     solution()


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort(reverse=True)
f = False
for i in range(n-2):
    if(arr[i] > arr[i+1] + arr[i+2]):
        f = True
        break
if f:
    print('No')
else:
    print('Yes')
    print(arr[n-3], arr[n-1], arr[n-2], end = ' ')
    for i in range(n-3):
        print(arr[i], end = ' ')


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort(reverse=True)
f = False
for i in range(n-2):
    if(arr[i] > arr[i+1] + arr[i+2]):
        f = True
        break
if f:
    print('NO')
else:
    print('YES')
    print(arr[n-3], arr[n-1], arr[n-2], end = ' ')
    for i in range(n-3):
        print(arr[i], end = ' ')


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
f = False
if(arr[n-1] >= arr[n-2] + arr[n-3]):
    f = True
if f:
    print('NO')
else:
    print('YES')
    print(arr[n-3], arr[n-1], arr[n-2], end = ' ')
    for i in range(n-4, -1, -1):
        print(arr[i], end = ' ')


n=int(input())
li = list(map(int,input().split(" ",n)[:n]))
li.sort()
if len(li)==3:
    if li[0]+li[1]>li[2]:
        print("YES")
        print(li[0],li[2],li[1])
    else:
        print("NO")
else:
    x=[]
    x.append(li[1])
    x.append(li[0])
    for i in range(n-2):
        x.append(li[i+2])
    fl=0
    if(x[0]>=x[n-1]+x[1] or x[n-1]>=x[n-2]+x[0]):
        fl=1
    for i in range(1,n-1):
        if(x[i]>=x[i+1]+x[i-1]):
            fl=1
            break
    if(fl==1):
        print("NO")
    else:
        print("YES")
        x = [str(a) for a in x]
        print(" ".join(x))


n=int(input())
li = list(map(int,input().split(" ",n)[:n]))
li.sort()
if(li[n-1]>=li[n-2]+li[n-3]):
    print("NO")
else:
    print("YES")
    print(li[n-2],li[n-1],li[n-3],end=" ")
    for i in range(n-4,-1,-1):
        print(li[i],end=" ")
    print("")


n=int(input())
a=[]
a=input().split(' ')
for i in range (n):
    a[i]=int(a[i])
b=sorted(a)
c=a
j=n-1
ram=0
z=n-1
x=0
for k in range (n):
    if(k%2==0):
        c[x]=b[n-1-k]
        x+=1
    else:
        c[z]=b[n-1-k]
        z-=1
while(j>=0):
    l=(j+n-1)%n
    r=(j+n+1)%n
    if(c[j]<(c[l]+c[r])):
        ram=0
    else:
        ram=1
        break
    j-=1
if(ram==0):
    print(c)
else:
    print('NO')


n=int(input())
a=[]
a=input().split(' ')
for i in range (n):
    a[i]=int(a[i])
b=sorted(a)
c=a
j=n-1
ram=0
z=n-1
x=0
for k in range (n):
    if(k%2==0):
        c[x]=b[n-1-k]
        x+=1
    else:
        c[z]=b[n-1-k]
        z-=1
while(j>=0):
    l=(j+n-1)%n
    r=(j+n+1)%n
    if(c[j]<(c[l]+c[r])):
        ram=0
    else:
        ram=1
        break
    j-=1
if(ram==0):
    print('YES')
    print(c)
else:
    print('NO')


n=int(input())
a=[]
a=input().split(' ')
for i in range (n):
    a[i]=int(a[i])
b=sorted(a)
j=n-1
ram=0
while(j>=0):
    l=(j+n-1)%n
    r=(j+n+1)%n
    if(b[j]<(b[l]+b[r])):
        ram=0
    else:
        ram=1
        break
    j-=1
if(ram==0):
    print(b)
else:
    print('NO')


n=int(input())
a=[]
a=input().split(' ')
for i in range (n):
    a[i]=int(a[i])
b=sorted(a)
c=a
j=n-1
ram=0
z=n-1
x=0
for k in range (n):
    if(k%2==0):
        c[x]=b[n-1-k]
        x+=1
    else:
        c[z]=b[n-1-k]
        z-=1
while(j>=0):
    l=(j+n-1)%n
    r=(j+n+1)%n
    if(c[j]<(c[l]+c[r])):
        ram=0
    else:
        ram=1
        break
    j-=1
if(ram==0):
    print('YES ')
    for itm in c:
        print(itm,end=' ')
else:
    print('NO')


n  = int(input())
nums = input().split()
a = []
for i in nums:
    a.append(int(i))

a.sort()

if a[n-1] > a[n-2] + a[n-3]:
    print("NO")
else:
    print("YES")
    result = f"{a[n-3]} {a[n-1]} {a[n-2] } "
    for i in range(n-4,-1,-1) :
        result += str(a[i]) + " "
    print(result)


n  = int(input())
nums = input().split()
a = []
for i in nums:
    a.append(int(i))

a.sort()

if a[n-1] >= a[n-2] + a[n-3]:
    print("NO")
else:
    print("YES")
    result = f"{a[n-3]} {a[n-1]} {a[n-2] } "
    for i in range(n-4,-1,-1) :
        result += str(a[i]) + " "
    print(result)


n=int(input())
x=list(map(int,input().rstrip().split()))
x=sorted(x)
d=[0]*n
if x[0]<x[1]+x[-1]:
    d[0]=1
if x[n-1]<x[n-2]+x[0]:
    d[n-1]=1
for i in range(1,n-1):
   if x[i]<x[i-1]+x[i+1]:
       d[i]=1
z=min(d)
if (z==1):
    print("YES")
else:
    print("NO")


n=int(input())
x=list(map(int,input().rstrip().split()))
x=sorted(x)
d=[0]*n
if x[0]<x[1]+x[-1]:
    d[0]=1
if x[n-1]<x[n-2]+x[0]:
    d[n-1]=1
for i in range(1,n-1):
   if x[i]<x[i-1]+x[i+1]:
       d[i]=1
z=min(d)
if (z==1):
    print("YES")
    str1 = ' '.join(str(e) for e in x)
    print(str1)
else:
    print("NO")


n = int(input())
x= list(map(int, input().split()))
x=sorted(x)
if x[n-1]>=x[n-2] + x[n-3]:
    print("NO")
else:
    print("YES")
    for i in range(n-1, -1, -2):
        print(x[i], end = " ")
    for i in range(n%2, n, 2):
        print(x[i], end = " ")


while True:
    try:
        n,crcle=int(input()),list(map(int,input().split()))
        crcle.sort()
        flag=True
        for i in range(n):
            if(i==0):
                if(crcle[i]>=crcle[-1]+crcle[i+1]):
                    flag=False
            elif(i==n-1):
                if(crcle[i]>=crcle[0]+crcle[i-1]):
                    flag=False

            if(flag==False):
                break
        if(flag):
            print("YES")
            print(*crcle)
        else:
            print("NO")

    except EOFError:
        break


while True:
    try:
        n,crcle=int(input()),list(map(int,input().split()))
        crcle.sort()
        flag=True
        for i in range(n):
            if(i==0):
                if(crcle[i]>=crcle[-1]+crcle[i+1]):
                    flag=False
            elif(i==n-1):
                if(crcle[i]>=crcle[0]+crcle[i-1]):
                    flag=False
            elif(crcle[i]>=crcle[i+1]+crcle[i-1]):
                flag=False
            if(flag==False):
                break
        if(flag):
            print("YES")
            print(*crcle)
        else:
            print("NO")

    except EOFError:
        break


while True:
    try:
        n,crcle=int(input()),list(map(int,input().split()))
        crcle.sort()
        if(crcle[n-1]>=crcle[n-2]+crcle[n-3]):
            print("NO")
        else:
            crcle[n-2],crcle[n-1]=crcle[n-1],crcle[n-2]
            print("YES")
            print(*crcle)

    except EOFError:
        break


while True:
    try:
        n,crcle=int(input()),list(map(int,input().split()))
        crcle.sort()
        flag=True
        for i in range(1):
            if(crcle[n-1]>=crcle[0]+crcle[1]):
                flag=False
        if(flag):
            print("YES")
            print(*crcle)
        else:
            print("NO")

    except EOFError:
        break


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1]+a[2]:
    print("NO")
else:
    print("YES")
    print(a[2], a[0], a[1], *a[3:])


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1]+a[2]:
    print("NO")
else:
    print("YES")
print(a[0], a[2], a[1], *a[3:])


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1]+a[2]:
    print("NO")
else:
    print("YES")
print(a[0], a[2], a[1], *reversed(a[3:]))


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1]+a[2]:
    print("NO")
else:
    print("YES")
print(*[a[1], a[0], a[2], *a[2:]])


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1]+a[2]:
    print("NO")
else:
    print("YES")
print(a[2], a[0], a[1], *a[3:])


n = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
if a[0] >= a[1] + a[2]:
    print("NO")
else:
    print("YES")
print(a[1], a[0], a[2], a[3:])


input()
a=list(map(int, input().split()))
a.sort()
if a[0]+a[-2]>a[-1]:
    print('YES')
    print(*a)
else:
    print('NO')


input()
a=list(map(int, input().split()))
a.sort()
a[-1], a[-2]=a[-2], a[-1]
if a[-3]+a[-1]>a[-2]:
    print('YES')
    print(*a)
else:
    print('NO')


n = int(input())
array = list(input().split(' '))
array = [int(i) for i in array]
array.sort()
if (array[n-1] >= array[n-2] + array[n-3]):
    print('NO')
else:
    print('YES')
    ans = list()
    for i in range(n):
        if i % 2 == 1:
            ans = ans + [array[i]]
        else:
            ans = [array[i]] + ans
    for i in ans:
        print(i)


n = int(input())
array = list(input().split(' '))
array = [int(i) for i in array]
array.sort()
if (array[n-1] >= array[n-2] + array[n-3]):
    print('NO')
else:
    print('YES')
    array = array[::-1]
    for i in range(0, n):
        if i % 2 == 0:
            print(array[i])
    for i in range(0, n)[::-1]:
        if i % 2 == 1:
            print(array[i])


n = int(input())
array = list(input().split(' '))
array = [int(i) for i in array]
array.sort()
if (array[n-1] >= array[n-2] + array[0]):
    print('NO')
else:
    print('YES')
    for i in array:
        print(i)


n = int(input())
array = list(input().split(' '))
array.sort()
array = [int(i) for i in array]
if (array[-1] >= array[-2] + array[0]):
    print('NO')
else:
    print('YES')
    for i in array:
        print(i)


x = int(input())
l = list(map(int,input().split()))
def MergeSort(l):
	if len(l) > 1:
		mid = len(l)//2
		lefthalf = l[:mid]
		righthalf = l[mid:]
		i = 0
		j = 0
		k = 0
		while j < len(lefthalf) and i < len(righthalf):
			if righthalf[i] <lefthalf[j]:
				l[k] = righthalf[i]
				i = i + 1
				k = k + 1
			else:
				l[k] = lefthalf[j]
				j = j + 1
				k = k + 1
		while j < len(lefthalf):
			l[k] = lefthalf[j]
			k = k + 1
			j = j + 1
		while i < len(righthalf):
			l[k] = righthalf[i]
			k = k + 1
			i = i + 1
k = 0
if l[x-2] + l[x-3] <=l[x-1]:
	print("NO")
else:
	print("YES")
	print(l[x-2],end=" ")
	for i in range(x):
		if i == len(l)-2:
			continue
		print(l[i],end=" ")


x = int(input())
l = list(map(int,input().split()))
def QuickSort(l,low,high):
	if low <= high:
		i = low
		j = low
		while i < high:
			if l[i] < l[high]:
				l[j],l[i] = l[i],l[j]
				j = j + 1
			i = i + 1
		l[j],l[high]= l[high],l[j]
		pi = j
		QuickSort(l,low,pi-1)
		QuickSort(l,pi+1,high)
QuickSort(l,0,len(l)-1)
s = ""
k = 0
if l[x-2] + l[x-3] <=l[x-1]:
	print("NO")
else:
	print("YES")
	print(l[x-2],end=" ")
	for i in range(x):
		if i == len(l)-2:
			continue
		print(l[i],end=" ")


x = int(input())
l = list(map(int,input().split()))
def MergeSort(l):
	if len(l) > 1:
		mid = len(l)//2
		lefthalf = l[:mid]
		righthalf = l[mid:]
		i = 0
		j = 0
		k = 0
		MergeSort(righthalf)
		MergeSort(lefthalf)
		while j < len(lefthalf) and i < len(righthalf):
			if righthalf[i] <lefthalf[j]:
				l[k] = righthalf[i]
				i = i + 1
				k = k + 1
			else:
				l[k] = lefthalf[j]
				j = j + 1
				k = k + 1
		while j < len(lefthalf):
			l[k] = lefthalf[j]
			k = k + 1
			j = j + 1
		while i < len(righthalf):
			l[k] = righthalf[i]
			k = k + 1
			i = i + 1
k = 0
MergeSort(l)
if l[x-2] + l[x-3] <= l[x-1]:
	print("NO")
else:
	print("YES")
	print(l[x-2],end=" ")
	for i in range(x):
		if i == len(l)-2:
			continue
		print(l[i],end=" ")


x = int(input())
l = list(map(int,input().split()))
# def MergeSort(l):
# 	if len(l) > 1:
# 		mid = len(l)//2
# 		lefthalf = l[:mid]
# 		righthalf = l[mid:]
# 		i = 0
# 		j = 0
# 		k = 0
# 		MergeSort(righthalf)
# 		MergeSort(lefthalf)
# 		while j < len(lefthalf) and i < len(righthalf):
# 			if righthalf[i] <lefthalf[j]:
# 				l[k] = righthalf[i]
# 				i = i + 1
# 				k = k + 1
# 			else:
# 				l[k] = lefthalf[j]
# 				j = j + 1
# 				k = k + 1
# 		while j < len(lefthalf):
# 			l[k] = lefthalf[j]
# 			k = k + 1
# 			j = j + 1
# 		while i < len(righthalf):
# 			l[k] = righthalf[i]
# 			k = k + 1
# 			i = i + 1
k = 0
l.sort()
if l[x-2] + l[x-3] <= l[x-1]:
	print("NO")
else:
	print("YES")
	print(l[x-2],end=" ")
	for i in range(x):
		if i == len(l)-2:
			continue
		print(l[i],end=" ")


n = int(input())
a = list(map(int,input().split()))
a.sort()
need = a[-1]-(a[0]+a[-2])
idex = -1
if n ==3 and a[0]+a[1]<=a[2]:
    print('NO')
elif n ==3 and a[0]+a[1]>a[2]:
    print('YES')
    print(*a)
else:
    a[0],a[-3] =a[-3],a[0]
    if a[0]+a[-2]>a[-1]:
        print('YES')
        print(*a)
    else:
        print('NO')


n = int(input())
a = list(map(int,input().split()))
a.sort()
need = a[-1]-(a[0]+a[-2])
idex = -1
if need>=0:
    need = a[-2]-a[0]
    for i in range(1,n-2):
        if a[i]+a[-2]>a[-1]:
            idex=i
            break
    if idex>-1:
        a[0],a[idex]= a[idex],a[0]
    else:
        print('NO')
        exit()
print('YES')
print(*a)


n = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0]<a[1]+a[-1] and a[-1]<a[0]+a[-2]:
    for i in range(1,n-1):
        if not(a[i]<a[i-1]+a[i+1]):
            print('NO')
            exit()
    print('YES')
    print(*a)
else:
    print('NO')


n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0]*n
i=-1
j=n-2
ans[1]=a[-1]
ans[0]=a[-2]
cur = 1
while(i!=j):
    need = ans[cur]-ans[cur-1]
    if need<=0:
        i+=1
        if i!=j:
            ans[cur+1]=a[i]
    else:
        j -= 1
        if j != i:
            ans[cur + 1] = a[j]
    if i == j:
        if not (ans[cur] < ans[-2] + ans[1]):
            print('NO')
            exit()
    else:
        if not (ans[cur] < ans[cur -1] + ans[cur + 1]):
            print('NO')
            exit()
    cur+=1
print('YES')
print(*ans)


n = int(input())
a = list(map(int,input().split()))
a.sort()
need = a[-1]-(a[0]+a[-2])
cur =1
if need>=0:
    arr=[0]*n
    arr[0]=a[-1]
    a.pop()
    arr[-1]=a.pop()
    if arr[0]>=arr[-1]+a[-1]:
        print('NO')
        exit()
    else:
        arr[1] = a.pop()
        for i in range (1,n-2):
            arr[i+1]=a.pop()
            if arr[i]>=arr[i-1]+arr[i+1]:
                print('NO')
                exit()
        if arr[n-2]>=arr[n-3]+arr[n-1]:
            print('NO')
            exit()
    print('YES')
    print(*arr)
    exit()
print('YES')
print(*a)


n = int(input())
a = list(map(int,input().split()))
a.sort()
need = a[-1]-(a[0]+a[-2])
idex = -1
if need>=0:
    need = a[-2]-a[0]
    for i in range(n-1):
        if a[i]+a[-2]>a[-1]:
            idex=i
            break
    if idex>-1:
        a[0],a[idex]= a[idex],a[0]
    else:
        print('NO')
        exit()
print('YES')
print(*a)


# cook your dish here
n=int(input())
y=list(map(int,input().split()))
y=sorted(y)
if y[-1]<y[0]+y[-2]:
    print("YES")
    print(*y)
else:
    if y[-1]<y[-2]+y[-3]:
        print("YES")
        print(*y)
    else:
        print("NO")


# cook your dish here
n=int(input())
y=list(map(int,input().split()))
y=sorted(y)
if y[-1]<y[0]+y[-2]:
    print("YES")
    print(*y)
else:
    if y[-1]<y[-2]+y[-3]:
        t=y[-1]
        y[-1]=y[-2]
        y[-2]=t
        print("YES")
        print(*y)
    else:
        print("NO")


def arun(arr):
    return sorted(arr)
n=int(input())
arr=list(map(int,input().split()))
arr=arun(arr)
ans=["NO","YES"]
ind=1
for i in range(n):
    if(arr[i]>=arr[(i-1)]+arr[(i+1)%n]):
        ind=0
        print(ans[0])
if(ind):
    print(ans[1])
    print(arr)


def arun(arr):
    return sorted(arr)
n=int(input())
arr=list(map(int,input().split()))
arr=arun(arr)
ans=["NO","YES"]
ind=1
for i in range(n):
    if(arr[i]>=arr[(i-1)]+arr[(i+1)%n]):
        ind=0
        print(ans[0])
if(ind):
    print(ans[1])
    for i in range(n):
        print(arr[i],end=" ")
    print()


def arun(arr):
    return sorted(arr)
n=int(input())
arr=list(map(int,input().split()))
arr=arun(arr)
arr=arr[:n-2]+[arr[-1]]+arr[n-2:n-1]
# print(arr)
ans=["NO","YES"]
ind=1
for i in range(n):
    if(arr[i]>=arr[(i-1)]+arr[(i+1)%n]):
        ind=0
        print(ans[0])
if(ind):
    print(ans[1])
    for i in range(n):
        print(arr[i],end=" ")
    print()


n = int(input())
nums = input().split(' ')
max3 = [0, 0, 0]
strout = ''
for num in nums:
    num = int(num)
    if num > max3[0]:
        max3[2] = max3[1]
        max3[1] = max3[0]
        max3[0] = num
    elif num > max3[1]:
        max3[2] = max3[1]
        max3[1] = num
    elif num > max3[2]:
        max3[2] = num
for m in max3:
    if m != 0:
        nums.remove(str(m))
        nums.sort(key=int)
if max3[0] > max3[1] + max3[2]:
    strout += 'NO\n'
else:
    strout += 'YES\n'
    strout += str(max3[1]) + ' ' + str(max3[0]) + ' ' + \
        str(max3[2]) + ' ' + ' '.join(nums)
print(strout)


n = int(input())
nums = input().split(' ')
max3 = [0, 0, 0]
strout = ''
for num in nums:
    num = int(num)
    if num > max3[0]:
        max3[0] = num
    elif num > max3[1]:
        max3[1] = num
    elif num > max3[2]:
        max3[2] = num
for m in max3:
    nums.remove(str(m))
    nums.sort(key=int)
if max3[0] > max3[1] + max3[2]:
    strout += 'NO\n'
else:
    strout += 'YES\n'
    strout += str(max3[1]) + ' ' + str(max3[0]) + ' ' + \
        str(max3[2]) + ' ' + ' '.join(nums)
print(strout)


n = int(input())
nums = input().split(' ')
max3 = [0, 0, 0]
strout = ''
for num in nums:
    num = int(num)
    if num > max3[0]:
        max3[2] = max3[1]
        max3[1] = max3[0]
        max3[0] = num
    elif num > max3[1]:
        max3[2] = max3[1]
        max3[1] = num
    elif num > max3[2]:
        max3[2] = num
for m in max3:
    if m != 0:
        nums.remove(str(m))
        nums.sort(key=int)
if max3[0] >= max3[1] + max3[2]:
    strout += 'NO\n'
else:
    strout += 'YES\n'
    strout += str(max3[1]) + ' ' + str(max3[0]) + ' ' + \
        str(max3[2]) + ' ' + ' '.join(nums)
print(strout)


n = int(input())
a = [int(x) for x in range (n)]
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
    print("NO")
else:
    print("YES")
    for i in range(n-1, -1, -2):
        print(a[i], end = " ")
    for i in range(n%2, n, 2):
        print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
    print("NO")
else:
    print("YES")
    for i in range(n-1, -1, -2):
        print(a[i], end = " ")
    for i in range(n%2, n, 2):
        print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(0,n):
	    print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(n-1,-1,-2):
	    print(a[i], end = " ")
    for i in range(n,n%2,-2):
         print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(n-1,-1,-2):
	    print(a[i], end = " ")
    for i in range(n%2,n,2):
         print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(n-1, -1, -1):
	    print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(n-1,-1,-2):
	    print(a[i], end = " ")
    for i in range(n,n%2,2):
         print(a[i], end = " ")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n-1]>=a[n-2] + a[n-3]:
	print("NO")
else:
    print("YES")
    for i in range(0,n,2):
	    print(a[i], end = " ")
    for i in range(n%2,n,2):
         print(a[i], end = " ")


n=int(input())
x=list(map(int,input().split()))
x.sort()

if x[n-1]<(x[0]+x[n-2]):
    print('YES')
    for i in x:
        print(i,end=' ')

else:
    s=x[n-2]+x[n-3]
    if s>x[n-1]:
        print('YES')
        x[n-2],x[n-1]=x[n-1],x[n-2]
        for i in x:
            print(i,end=' ')
    else:
        print('NO')


n=int(input())
x=list(map(int,input().split()))
x.sort()
q=True
for i in range(1,n-1):
    if x[i]<(x[i-1]+x[i+1]):
        q=True
    else:
        q=False
        break

if x[n-1] < (x[0]+x[n-2]):
    q=True
else:
    q=False

if q==False:
    print('NO')
else:
    print('YES')
    for i in x:
        print(i,end=' ')


input()
a=sorted(map(int,input().split()))[::-1]
a[:2]=a[1::-1]
if a[1]<a[0]+a[2]:print('YES',*a)
else:print('NO')


input()
a=sorted(map(int,input().split()))
if a[-1]<a[-2]+a[-3]:print('YES',*a[:-2],*a[:-3:-1])
else:print('NO')


input()
a=sorted(map(int,input().split()))
a[-2:]=a[:-3:-1]
if a[-2]<a[-3]+a[-1]:print('YES',*a)
else:print('NO')


x=int(input())
s=sorted(list(map(int,input().split())))
l=0
for n in range(1,x-1):
    if s[n-1]+s[n+1]<=s[n]:
        l=1
        print('NO')
        break
if l==0:
    if s[0]+s[-2]>s[-1]:
        print('YES')
        print(*s)
    else:
        k=s[0]
        for n in s:
            if n>k:
                break
        t=s[0]
        s[0]=n
        s[1]=t
        if s[0]+s[-2]>s[-1]:
            print('YES')
            print(*s)
        else:
            print('NO')


x=int(input())
s=sorted(list(map(int,input().split())))
l=0
if s[-2]+s[-3]>s[-1]:
    print('YES')
    for n in range(x-3):
        print(s[n],end=' ')
    print(s[x-3],s[x-1],s[x-2])
else:
    print('NO')


x=int(input())
s=sorted(list(map(int,input().split())))
l=0
if s[-2]+s[0]>s[-1]:
    print('YES')
    for n in range(x-3):
        print(s[n],end=' ')
    print(s[x-3],s[x-1],s[x-2])
else:
    print('NO')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul  8 23:06:27 2019

@author: majd
"""

#import sys
#class RedirectInput:
#    def __init__(self):
#        self.f = open('input', 'r')
#
#
#    def readline(self):
#        s = self.f.readline()
#        return s
#
#    def __del__(self):
#        self.f.close()
#sys.stdin = RedirectInput()

def check(ol):
    l = [i for i in ol]
    ok = True
    l1 = l[:2]
#    print(l)
    l.append(l1[0])
    l.append(l1[1])
#    print(l)
    for i in range(len(l)-2):
        if(l[i] + l[i+2] <= l[i+1]):
            ok = False
            return ok
#    if(l[i+1] + l[len(l)-1] <= l[i]):
#        ok = False
#        return ok
#    if(l[i] + l[len(l)-2] <= l[len(l)-1]):
#        ok = False
#        return ok
    return ok

n = int(input())
l = list(map(int, input().split(" ")))
l.sort(reverse = True)

ansL = list()
ansR = list()
for i in range(len(l)):
    if(i%2 == 0):
        ansL.append(l[i])
    else:
        ansR.append(l[i])

for i in reversed(ansR):
    ansL.append(i)

yes = check(ansL)

print("YES" if yes else "NO")
print(ansL)


# -*- coding: utf-8 -*-
"""
Created on Mon Jul  8 23:06:27 2019

@author: majd
"""

#import sys
#class RedirectInput:
#    def __init__(self):
#        self.f = open('input', 'r')
#
#
#    def readline(self):
#        s = self.f.readline()
#        return s
#
#    def __del__(self):
#        self.f.close()
#sys.stdin = RedirectInput()

def check(ol):
    l = [i for i in ol]
    ok = True
    l1 = l[:2]
#    print(l)
    l.append(l1[0])
    l.append(l1[1])
#    print(l)
    for i in range(len(l)-2):
        if(l[i] + l[i+2] <= l[i+1]):
            ok = False
            return ok
#    if(l[i+1] + l[len(l)-1] <= l[i]):
#        ok = False
#        return ok
#    if(l[i] + l[len(l)-2] <= l[len(l)-1]):
#        ok = False
#        return ok
    return ok

n = int(input())
l = list(map(int, input().split(" ")))
l.sort(reverse = True)

ansL = list()
ansR = list()
for i in range(len(l)):
    if(i%2 == 0):
        ansL.append(l[i])
    else:
        ansR.append(l[i])

for i in reversed(ansR):
    ansL.append(i)

yes = check(ansL)

print("YES" if yes else "NO")
if(yes):
    print(' '.join([str(i) for i in ansL]))


# -*- coding: utf-8 -*-
"""
Created on Mon Jul  8 23:06:27 2019

@author: majd
"""

#import sys
#class RedirectInput:
#    def __init__(self):
#        self.f = open('input', 'r')
#
#
#    def readline(self):
#        s = self.f.readline()
#        return s
#
#    def __del__(self):
#        self.f.close()
#sys.stdin = RedirectInput()

def check(ol):
    l = [i for i in ol]
    ok = True
    l1 = l[:2]
#    print(l)
    l.append(l1[0])
    l.append(l1[1])
#    print(l)
    for i in range(len(l)-2):
        if(l[i] + l[i+2] <= l[i+1]):
            ok = False
            return ok
#    if(l[i+1] + l[len(l)-1] <= l[i]):
#        ok = False
#        return ok
#    if(l[i] + l[len(l)-2] <= l[len(l)-1]):
#        ok = False
#        return ok
    return ok

n = int(input())
l = list(map(int, input().split(" ")))
l.sort(reverse = True)

ansL = list()
ansR = list()
for i in range(len(l)):
    if(i%2 == 0):
        ansL.append(l[i])
    else:
        ansR.append(l[i])

for i in reversed(ansR):
    ansL.append(i)

yes = check(ansL)

print("YES" if yes else "NO")
print(' '.join([str(i) for i in ansL]))


n = int(input())
lst = list(map(int,input().split()))
lst.sort()
#print(lst)
if (lst[0] + lst[n-2] <= lst[n-1]):
    if (lst[n-1] < lst[n-2] +lst[n-3]):
        print("YES")
        tmp = lst[n-2]
        lst[n-2]=lst[n-1]
        lst[n-1]=tmp
        print(" ".join(map(str,lst)))
    else:
        print("NO")
else:
    print("YES")
    print(" ".join(map(str,lst)))


n = int(input())
lst = list(map(int,input().split()))
lst.sort()
#print(lst)
if (lst[0] + lst[n-2] <= lst[n-3]):
    if (lst[n-1] < lst[n-2] +lst[n-3]):
        print("YES")
        tmp = lst[n-2]
        lst[n-2]=lst[n-3]
        lst[n-3]=tmp
        print(" ".join(map(str,lst)))
    else:
        print("NO")
else:
    print("YES")
    print(" ".join(map(str,lst)))


n = int(input())
lst = list(map(int,input().split()))
lst.sort()
#print(lst)
if (lst[0] + lst[n-2] <= lst[n-3]):
    if (lst[n-1] < lst[n-2] +lst[n-3]):
        print("YES")
        tmp = lst[n-2]
        lst[n-2]=lst[n-1]
        lst[n-1]=tmp
        print(" ".join(map(str,lst)))
    else:
        print("NO")
else:
    print("YES")
    print(" ".join(map(str,lst)))


while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]>=a[n-2]+a[n-3]:
			print("NO")
		else:
			x=a[n-1]
			a[n-1]=a[n-2]
			a[n-2]=x
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		b=[]
		for i in range(n//2,n):
			b.append(a[i])
		j=n//2
		i=n-(n//2)-1
		# print(a,b,i,j)
		while j<n:
			a[j]=b[i]
			i=i-1
			j=j+1
		# print(a,b)
		f=1
		for i in range(0,n):
			if a[i]>a[(i-1+n)%n]+a[(i+1)%n]:
				f=0
		if f==0:print('NO')
		else:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
	except:break


while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]>a[n-2]+a[n-3]:
			print("NO")
		else:
			x=a[n-1]
			a[n-1]=a[n-2]
			a[n-2]=x
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
	except:break


import matplotlib.pyplot as plt
import numpy as np
from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

# draw_picture()
while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]>a[n-2]+a[n-3]:
			print("NO")
		else:
			x=a[n-1]
			a[n-1]=a[n-2]
			a[n-2]=x
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			id=0
			for i in range(1,n-2):
				if a[i]+a[n-2]>a[n-1]:
					x=a[i]
					a[i]=a[0]
					a[0]=x
					id=i
			f=1
			if a[id-1]>a[id]+a[(id-2+n)%n]:
				for i in range(id+1,n-2):
					x=a[i]
					a[i] = a[i-1]
					a[i-1] = x
					if a[i-1]<a[(i-2+n)%n]+a[i]:
						f=0
						break
			if f:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			id=0
			for i in range(1,n-2):
				if a[i]+a[n-2]>a[n-1]:
					x=a[i]
					a[i]=a[0]
					a[0]=x
					id=i
			# print(id)
			f=1
			if id==0:
				print('NO')
				continue
			if a[id-1]>a[id]+a[(id-2+n)%n]:
				for i in range(id+1,n-2):
					x=a[i]
					a[i] = a[i-1]
					a[i-1] = x
					if a[i-1]<a[(i-2+n)%n]+a[i]:
						f=0
						break
			else:f=0
			if f:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			f=0
			for i in range(1,n-2):
				if a[n-2]+a[i]>a[n-1]:
					f=a[i]
					a[i]=a[0]
					a[0]=f
					f=1
			if f==0:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			f=0
			for i in range(1,n-2):
				if a[n-2]+a[i]>a[n-1]:
					f=a[i]
					a[i]=a[0]
					a[1]=f
					f=1
			if f==0:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		b=[]
		for i in range(n//2,n):
			b.append(a[i])
		j=n//2
		i=n-(n//2)-1
		# print(a,b,i,j)
		while j<n:
			a[j]=b[i]
			i=i-1
			j=j+1
		# print(a,b)
		f=1
		for i in range(0,n):
			if a[i]>=a[(i-1+n)%n]+a[(i+1)%n]:
				f=0
		if f==0:print('NO')
		else:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
	except:break


# import matplotlib.pyplot as plt
# import numpy as np
from numpy import pi
def exercise():
	while True:
		try:
			n=int(input())
			a=list(map(int,input().split()))
			a.sort()
			if a[n-1]>a[n-2]+a[n-3]:
				print("NO")
			else:
				x=a[n-1]
				a[n-1]=a[n-2]
				a[n-2]=x
				print('YES')
				for x in a:
					print(x,end=" ")
				print()
		except:break
def draw_picture():
	population_profit=np.genfromtxt("exercise/ex1/ex1data1.txt",delimiter=',',dtype=float)
	# print(population_profit.dtype)
	# print(population_profit)
	population=population_profit[:,0]
	profit=population_profit[:,1]
	plt.plot(population,profit,)
	plt.show()
# draw_picture()
exercise();


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			f=0
			for i in range(1,n-2):
				if a[n-2]+a[i]>a[n-1]:
					f=a[i]
					a[i]=a[1]
					a[1]=f
					f=1
			if f==0:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


def import_package():
	import matplotlib.pyplot as plt
	import numpy as np
	from numpy import pi

def draw_picture():
	x=np.linspace(0,2*pi,1000)
	y=np.sin(x)
	plt.plot(x,y)
	plt.show()

while True:
	try:
		n=int(input())
		a=list(map(int,input().split()))
		a.sort()
		if a[n-1]<a[0]+a[n-2]:
			print('YES')
			for x in a:
				print(x,end=" ")
			print()
		else:
			id=0
			for i in range(1,n-2):
				if a[i]+a[n-2]>a[n-1]:
					x=a[i]
					a[i]=a[0]
					a[0]=x
					id=i
			f=1
			if id==0:
				print('NO')
				continue
			if a[id-1]>a[id]+a[(id-2+n)%n]:
				for i in range(id+1,n-2):
					x=a[i]
					a[i] = a[i-1]
					a[i-1] = x
					if a[i-1]<a[(i-2+n)%n]+a[i]:
						f=0
						break
			if f:print('NO')
			else:
				print('YES')
				for x in a:
					print(x, end=" ")
				print()
	except:break


n=input()
a=list(map(int,input().split(' ')))

a=sorted(a)
if(a[n-1]>=a[n-2]+a[n-3]):
    cout<<"NO"
else:
    tmp=a[n-1]
    a[n-1]=a[n-2]
    a[n-2]=tmp
    print("YES")
    print(' '.join(a))


n=int(input())
a=list(map(int,input().split(' ')))

a=sorted(a)
if(a[n-1]>=a[n-2]+a[n-3]):
    print("NO")
else:
    tmp=a[n-1]
    a[n-1]=a[n-2]
    a[n-2]=tmp
    print("YES")
    for i in a:
        print(i,end=' ')


n=int(input())
a=list(map(int,input().split(' ')))

a=sorted(a)
if(a[n-1]>=a[n-2]+a[n-3]):
    cout<<"NO"
else:
    tmp=a[n-1]
    a[n-1]=a[n-2]
    a[n-2]=tmp
    print("YES")
    for i in a:
        print(i,end=' ')


n=input()
a=list(map(int,input().split(' ')))

a=sorted(a)
if(a[n-1]>=a[n-2]+a[n-3]):
    print("NO")
else:
    tmp=a[n-1]
    a[n-1]=a[n-2]
    a[n-2]=tmp
    print("YES")
    print(' '.join(a))


n=int(input())
s=[int(x) for x in input().split()]
arr1=sorted(s)
arr=[]
c=0
for i in range(0,len(arr1)):
    c+=1
    if(c%2==0):
        arr.insert(0,arr1[i])
    else:
        arr.append(arr1[i])
flag=0
for i in range(1,len(arr)-1):
    if(arr[i]>=arr[i-1]+arr[i+1]):
        flag=1
        break
if(arr[0]>=arr[1]+arr[-1]):
    flag=1
if(arr[-1]>=arr[0]+arr[-2]):
    flag=1
if(flag==1):
    print('NO')
else:
    print('YES')
    for j in range(0,len(arr)):
        print(arr[j],end=" ")
    print(" ")


n=int(input())
s=[int(x) for x in input().split()]
arr1=sorted(s)
arr=[0]*n
c=0
ptr1=n//2
ptr2=ptr1-1
while(ptr1<n or ptr2>=0):
    if(ptr1<n):
        arr[ptr1]=arr1[c]
        c+=1
        ptr1+=1
    if(ptr2>=0):
        arr[ptr2]=arr1[c]
        c+=1
        ptr2-=1

flag=0
for i in range(1,len(arr)-1):
    if(arr[i]>=arr[i-1]+arr[i+1]):
        flag=1
        break
if(arr[0]>=arr[1]+arr[-1]):
    flag=1
if(arr[-1]>=arr[0]+arr[-2]):
    flag=1
if(flag==1):
    print('NO')
else:
    print('YES')
    for j in range(0,len(arr)):
        print(arr[j],end=" ")
    print(" ")


n=int(input())
s=[int(x) for x in input().split()]
arr=sorted(s)
flag=0
for i in range(1,len(arr)-1):
    if(arr[i]>=arr[i-1]+arr[i+1]):
        flag=1
        break
if(arr[0]>=arr[1]+arr[-1]):
    flag=1
if(arr[-1]>=arr[0]+arr[-2]):
    flag=1
if(flag==1):
    print('NO')
else:
    print('YES')
    for j in range(0,len(arr)):
        print(arr[j],end=" ")
    print(" ")


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TwoSets {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        Pair[] parent = new Pair[n + 2];
        int[] rank = new int[n + 2];
        Map<Integer, Integer> map = new HashMap<>();
        makeSet(scanner, map, parent, rank, n);
        boolean attachA = false;
        boolean attachB = false;

        for (int i = 1; i <= n; i++) {
            int partnerA = a - parent[i].value;
            int partnerB = b - parent[i].value;
            Integer partnerAIndex = map.get(partnerA);
            Integer partnerBIndex = map.get(partnerB);
            if (partnerAIndex != null && partnerAIndex != i) {
                if (!attachA) {
                    attachA = true;
                    unionSet(parent, rank, i, 0);
                }
                unionSet(parent, rank, i, partnerAIndex);
            } else if (partnerBIndex != null && partnerBIndex != i) {
                if (!attachB) {
                    attachB = true;
                    unionSet(parent, rank, i, n + 1);
                }
                unionSet(parent, rank, i, partnerBIndex);
                parent[i].code = 1;
                parent[partnerBIndex].code = 1;
            } else {
                System.out.println("NO");
                return;
            }
        }

        String res = "";
        for (int i = 1; i <= n; i++) {
            res += i == 1 ? parent[i].code : " " + parent[i].code;
        }

        System.out.println("YES");
        System.out.println(res);
    }

    static class Pair {
        public int parent, value, code;
        public Pair (int parent, int value) {
            this.parent = parent;
            this.value = value;
            this.code = 0;
        }
    }

    private static void makeSet(Scanner scanner, Map<Integer, Integer> map, Pair[] parent, int[] rank, int n) {
        parent[0] = new Pair(0, 0);
        rank[0] = 1000000000;
        parent[n + 1] = new Pair(n + 1, 0);
        rank[n + 1] = 1000000000;
        for (int i = 1; i <= n; i++) {
            parent[i] = new Pair(i, scanner.nextInt());
            map.put(parent[i].value, i);
            rank[i] = 0;
        }
    }

    private static int findSet(Pair[] parent, int u) {
        if (parent[u].parent != u)
            parent[u].parent = findSet(parent, parent[u].parent);
        return parent[u].parent;
    }

    private static void unionSet(Pair[] parent, int[] rank, int u, int v) {
        int up = findSet(parent, u);
        int vp = findSet(parent, v);
        if (up == vp)
            return;
        if (rank[up] > rank[vp])
            parent[vp].parent = up;
        else if (rank[up] < rank[vp])
            parent[up].parent = vp;
        else {
            parent[up].parent = vp;
            rank[vp]++;
        }
    }
}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TwoSets {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (n % 2 != 0) {
            System.out.println("NO");
            return;
        }

        Pair[] parent = new Pair[n];
        int[] rank = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        makeSet(scanner, map, parent, rank, n);

        for (int i = 0; i < n; i++) {
            int partnerA = a - parent[i].value;
            int partnerB = b - parent[i].value;
            Integer partnerAIndex = map.get(partnerA);
            Integer partnerBIndex = map.get(partnerB);
            if (partnerAIndex != null && partnerAIndex != i) {
                unionSet(parent, rank, i, partnerAIndex);
            } else if (partnerBIndex != null && partnerBIndex != i) {
                unionSet(parent, rank, i, partnerBIndex);
                parent[i].code = 1;
                parent[partnerBIndex].code = 1;
            }
        }

        String res = "";
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (i == parent[i].parent)
                count++;

            if (count > 2) {
                System.out.println("NO");
                return;
            }

            res += i == 0 ? parent[i].code : " " + parent[i].code;
        }

        System.out.println("YES");
        System.out.println(res);
    }

    static class Pair {
        public int parent, value, code;
        public Pair (int parent, int value) {
            this.parent = parent;
            this.value = value;
            this.code = 0;
        }
    }

    private static void makeSet(Scanner scanner, Map<Integer, Integer> map, Pair[] parent, int[] rank, int n) {
        for (int i = 0; i < n; i++) {
            parent[i] = new Pair(i, scanner.nextInt());
            map.put(parent[i].value, i);
            rank[i] = 0;
        }
    }

    private static int findSet(Pair[] parent, int u) {
        if (parent[u].parent != u)
            parent[u].parent = findSet(parent, parent[u].parent);
        return parent[u].parent;
    }

    private static void unionSet(Pair[] parent, int[] rank, int u, int v) {
        int up = findSet(parent, u);
        int vp = findSet(parent, v);
        if (up == vp)
            return;
        if (rank[up] > rank[vp])
            parent[vp].parent = up;
        else if (rank[up] < rank[vp])
            parent[up].parent = vp;
        else {
            parent[up].parent = vp;
            rank[vp]++;
        }
    }
}


import java.io.*;
import java.util.*;

public class Solution_AC {
    static int[] par;
    static int find(int u) {
        if (u != par[u]) {
            par[u] = find(par[u]);
        }
        return par[u];
    }
    static void union(int u, int v) {
        u = find(u);
        v = find(v);
        par[u] = v;
    }
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        int[] p = new int[n];
        par = new int[n + 2];
        for (int i = 0; i <= n + 1; ++i) {
            par[i] = i;
        }
        Map<Integer, Integer> mp = new TreeMap<>();
        for (int i = 0; i < n; ++i) {
            p[i] = sc.nextInt();
            mp.put(p[i], i + 1);
        }

        for (int i = 0; i < n; ++i) {
            union(i + 1, mp.containsKey(a - p[i]) ? mp.get(a - p[i]) : n + 1);
            union(i + 1, mp.containsKey(b - p[i]) ? mp.get(b - p[i]) : 0);
        }

        int A = find(0), B = find(n + 1);
        if (A != B) {
            System.out.println("YES");
            for (int i = 1; i <= n; ++i) {
                System.out.print(find(i) == A ? "0 " : "1 ");
            }
        }
        else {
            System.out.print("NO");
        }
	}
}


import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		List<Clause> clauses = new ArrayList<Clause>();
		int[] p = new int[n];
		Map<Integer, Integer> id = new HashMap<>();
		for (int i = 0; i < n; i++) {
			p[i] = in.nextInt();
			id.put(p[i], i);
		}
		// var[i] = true means p[i] \in A
		for (int i = 0; i < n; i++) {
			int x = p[i];
			Integer j = id.get(a - x);
			if (j == null) {
				// var[i] is false
				clauses.add(new Clause(i, i, true, false));
			} else {
				clauses.add(new Clause(i, j, true, true));
				clauses.add(new Clause(j, i, false, false));
			}

			j = id.get(b - x);
			if (j == null) {
				// var[i] is true
				clauses.add(new Clause(i, i, false, true));
			} else {
				clauses.add(new Clause(i, j, false, false));
				clauses.add(new Clause(j, i, true, true));
			}
		}
		SAT2Solver solver = new SAT2Solver(n);
		if (!solver.solve(clauses)) {
			out.println("NO");
			return;
		}
		out.println("YES");
		for (int i = 0; i < n; i++) {
			if (i > 0) {
				out.print(" ");
			}
			if (solver.isTrue[i]) {
				out.print(0);
			} else {
				out.print(1);
			}
		}
		out.println();
	}

	class Clause {
		int v1, v2;
		boolean neg1, neg2;

		// Example: (x=>!y) is translated to Clause(x, y, true, false)
		Clause(int v1, int v2, boolean pos1, boolean pos2) {
			this.v1 = v1;
			this.v2 = v2;
			this.neg1 = !pos1;
			this.neg2 = !pos2;
		}
	}

	class SAT2Solver {
		List<Integer>[] g;
		boolean[] isTrue;
		int n;

		int numComps;
		int[] low;
		int[] vis;
		int[] comp;
		boolean[] onStack;
		int[] stack;
		int sp;
		int globalTime;

		SAT2Solver(int n) {
			this.n = n;
			isTrue = new boolean[2 * n];
			vis = new int[2 * n];
			low = new int[2 * n];
			stack = new int[2 * n];
			comp = new int[2 * n];
			onStack = new boolean[2 * n];
			g = new List[2 * n];
		}

		public boolean solve(List<Clause> clauses) {
			for (int i = 0; i < 2 * n; i++) {
				g[i] = new ArrayList<Integer>();
			}
			for (Clause clause : clauses) {
				int v1 = clause.v1;
				int v2 = clause.v2;
				boolean neg1 = clause.neg1;
				boolean neg2 = clause.neg2;
				if (neg1) {
					v1 = negate(v1);
				}
				if (neg2) {
					v2 = negate(v2);
				}
				//g[negate(v1, n)].add(v2);
				//g[negate(v2, n)].add(v1);
				g[v1].add(v2);
			}
			Arrays.fill(vis, -1);
			Arrays.fill(onStack, false);
			sp = 0;
			globalTime = 0;
			numComps = 0;
			for (int i = 0; i < 2 * n; i++) {
				if (vis[i] < 0) {
					dfsTarjan(i);
				}
			}
			int[] firstInComp = new int[numComps];
			Arrays.fill(firstInComp, -1);
			int[] nextSameComp = new int[2 * n];
			for (int i = 0; i < 2 * n; i++) {
				int c = comp[i];
				nextSameComp[i] = firstInComp[c];
				firstInComp[c] = i;
			}
			List<Integer>[] invertedCompEdges = new List[numComps];
			for (int i = 0; i < numComps; i++) {
				invertedCompEdges[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < 2*n; i++) {
				for (int j : g[i]) {
					invertedCompEdges[comp[j]].add(comp[i]);
				}
			}
			boolean[] compIsTrue = new boolean[numComps];
			Arrays.fill(compIsTrue, true);
			for (int c = 0; c < numComps; c++) {
				if (!compIsTrue[c]) {
					continue;
				}
				for (int i = firstInComp[c]; i >= 0; i = nextSameComp[i]) {
					int nc = comp[negate(i)];
					if (c == nc) {
						return false;
					}
				}
				for (int i = firstInComp[c]; i >= 0; i = nextSameComp[i]) {
					int nc = comp[negate(i)];
					dfsReject(nc, invertedCompEdges, compIsTrue);
				}
			}
			for (int i = 0; i < 2 * n; i++) {
				isTrue[i] = compIsTrue[comp[i]];
			}
			for (int i = 0; i < n; i++) {
				if (isTrue[i] && isTrue[negate(i)]) {
					throw new AssertionError();
				}
				if (!isTrue[i] && !isTrue[negate(i)]) {
					return false;
				}
			}
			return true;
		}

		private int negate(int i) {
			return i + (i < n ? n : -n);
		}

		private void dfsReject(int c, List<Integer>[] invertedCompEdges, boolean[] compIsTrue) {
			if (!compIsTrue[c]) {
				return;
			}
			compIsTrue[c] = false;
			for (int p : invertedCompEdges[c]) {
				dfsReject(p, invertedCompEdges, compIsTrue);
			}
		}

		void dfsTarjan(int v) {
			vis[v] = globalTime;
			low[v] = globalTime;
			++globalTime;
			stack[sp++] = v;
			onStack[v] = true;
			for (int u : g[v]) {
				if (vis[u] < 0) {
					dfsTarjan(u);
					if (low[v] > low[u]) {
						low[v] = low[u];
					}
				} else if (onStack[u] && low[v] > vis[u]) {
					low[v] = vis[u];
				}
			}
			if (low[v] == vis[v]) {
				while (true) {
					int u = stack[--sp];
					onStack[u] = false;
					comp[u] = numComps;
					if (u == v) {
						break;
					}
				}
				++numComps;
			}
		}

	}

}

class FastScanner {

	private BufferedReader in;
	private StringTokenizer st;

	public FastScanner(InputStream stream) {
		in = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				String rl = in.readLine();
				if (rl == null) {
					return null;
				}
				st = new StringTokenizer(rl);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            TreeMap<Integer, TreeSet<pair>> nums = new TreeMap<>();
            TreeMap<Integer, Integer> pos = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                int p = in.nextInt();
                nums.put(p, new TreeSet<>());
                pos.put(p, i);
            }
            TreeSet<pair> pairs = new TreeSet<>();
            for (int num : nums.keySet()) {
                if (nums.containsKey(a - num)) {
                    pair p = new pair(num, a - num);
                    pairs.add(p);
                    nums.get(num).add(p);
                }
                if (nums.containsKey(b - num)) {
                    pair p = new pair(num, b - num);
                    pairs.add(p);
                    nums.get(num).add(p);
                }
            }
            for (int num : nums.keySet()) {
                for (pair cur1 : nums.get(num)) {
                    for (pair cur2 : nums.get(num)) {
                        if (cur1 != cur2) {
                            cur1.dep.add(cur2);
                        }
                    }
                }
            }
            for (pair cur : pairs) {
                if (cur.live) {
                    for (pair dep : cur.dep) {
                        dep.live = false;
                    }
                }
            }
            int liveCnt = 0;
            for (pair cur : pairs) {
                if (cur.live) {
                    liveCnt++;
                }
            }
            if (liveCnt * 2 == n) {
                int[] ans = new int[n];
                for (pair cur : pairs) {
                    if (cur.live && cur.v1() + cur.v2() == b) {
                        ans[pos.get(cur.v1())] = 1;
                        ans[pos.get(cur.v2())] = 1;
                    }
                }
                out.println("YES");
                for (int i : ans) {
                    out.print(i);
                    out.print(' ');
                }
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class pair implements Comparable {
        private int v1;
        private int v2;
        TreeSet<pair> dep = new TreeSet<>();
        boolean live = true;

        pair(int v1, int v2) {
            this.v1 = Math.max(v1, v2);
            this.v2 = Math.min(v1, v2);
        }

        int v1() {
            return v1;
        }

        int v2() {
            return v2;
        }

        public int compareTo(Object o) {
            pair other = (pair) o;
            if (v1 != other.v1) return v1 - other.v1;
            if (v2 != other.v2) return v2 - other.v2;
            return 0;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int[] p = new int[n];
            TreeSet<Integer> nums = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
                nums.add(p[i]);
            }
            int[] ans = new int[n];
            for (int i = 0; i < n; i++) {
                if (!nums.contains(b - p[i]) && !nums.contains(a - p[i])) {
                    out.println("NO");
                    return;
                } else if (!nums.contains(a - p[i])) {
                    ans[i] = 1;
                }
            }
            out.println("YES");
            for (int i = 0; i < n; i++) {
                out.print(ans[i]);
                //out.print("(" + p[i] + ")");
                out.print(' ');
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int[] p = new int[n];
            TreeMap<Integer, Integer> nums = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
                nums.put(p[i], i);
            }
            dsu s = new dsu(n + 2);
            for (int i = 0; i < n; i++) {
                if (nums.containsKey(a - p[i])) {
                    s.union(i, nums.get(a - p[i]));
                } else {
                    s.union(i, n);
                }
                if (nums.containsKey(b - p[i])) {
                    s.union(i, nums.get(b - p[i]));
                } else {
                    s.union(i, n + 1);
                }
            }
            if (s.find(n) == s.find(n + 1)) {
                out.println("NO");
            } else {
                out.println("YES");
                for (int i = 0; i < n; i++) {
                    out.print(s.find(i) == s.find(n) ? 1 : 0);
                    out.print(' ');
                }
            }
        }

    }

    static class dsu {
        int[] parents;

        dsu(int n) {
            parents = new int[n];
            for (int i = 0; i < n; i++) {
                parents[i] = i;
            }
        }

        int find(int n) {
            if (parents[n] == n) return n;
            return parents[n] = find(parents[n]);
        }

        void union(int a, int b) {
            a = find(a);
            b = find(b);
            if (a != b) {
                parents[a] = b;
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}