#ifdef NALP_PROJECT
#pragma hdrstop
#else
#define _SECURE_SCL 0
#endif

#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:200000000")

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <utility>

#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <memory.h>

#include <iostream>
#include <sstream>

using namespace std;

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define y1 YYYYYYYYYYYY1
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; }
template<typename T> inline T sqr(T x) { return x * x; }
template<typename T> string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }

const int INF = (int)1E9;
const int64 INF64 = (int64)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;

const int MAXN = 100100;

pair<int64, int> p[MAXN], s[MAXN];
pair<int64, int> a[MAXN];
int64 h, ANS;
int n, ans[MAXN];

int64 calcByMask() {
	vector<int64> A, B;
	forn(i, n) {
		if (ans[i] == 0) A.pb(a[i].first);
		if (ans[i] == 1) B.pb(a[i].first);
	}

	int64 minv = INF64;
	if (A.size() >= 2) minv = min(minv, A[0] + A[1]);
	if (B.size() >= 2) minv = min(minv, B[0] + B[1]);
	if (!A.empty() && !B.empty()) minv = min(minv, A[0] + B[0] + h);

	reverse(all(A));
	reverse(all(B));

	int64 maxv = -INF64;
	if (A.size() >= 2) maxv = max(maxv, A[0] + A[1]);
	if (B.size() >= 2) maxv = max(maxv, B[0] + B[1]);
	if (!A.empty() && !B.empty()) maxv = max(maxv, A[0] + B[0] + h);

	return maxv - minv;
}

void printAnswer() {
	cout << ANS << endl;
	vector<int> res(n);
	forn(i, n)
		res[a[i].second] = ans[i];

	forn(i, n)
		cout << res[i] + 1 << " ";
	cout << endl;

	exit(0);
}

int64 solveByMask(bool print) {
	int64 res = INF64;
	forn(mask1, 4)
		forn(mask2, 4) {
			forn(i, 2)
				if ((mask1 & (1 << i)) != 0)
					ans[i] = 1;

			forn(i, 2)
				if ((mask2 & (1 << i)) != 0)
					ans[n - i - 1] = 1;

			int64 cur = calcByMask();
			if (print && cur == ANS) printAnswer();
			res = min(res, cur);

			ans[0] = ans[1] = ans[n - 1] = ans[n - 2] = 0;
		}

	return res;
}

int64 solveByCalc(bool print) {
	forn(i, n) {
		p[i] = mp(-INF64, -1);
		s[i] = mp(+INF64, -1);
	}

	int i0 = 0, i1 = 1, i2 = 2;
	for(int i = 3; i < n; i++) {
		p[i] = p[i - 1];

		{
			int64 cur = min(a[i0].first + a[i].first, min(a[i1].first + a[i2].first, a[i0].first + a[i1].first + h));
			p[i] = max(p[i], mp(cur, i));
		}

		{
			int64 cur = min(a[i0].first + a[i2].first, min(a[i1].first + a[i].first, a[i0].first + a[i1].first + h));
			p[i] = max(p[i], mp(cur, i));
		}
	}

	i0 = n - 1;
	i1 = n - 2;
	i2 = n - 3;
	for(int i = n - 4; i >= 0; i--) {
		s[i] = s[i + 1];

		{
			int64 cur = max(a[i0].first + a[i].first, max(a[i1].first + a[i2].first, a[i0].first + a[i1].first + h));
			s[i] = min(s[i], mp(cur, i));
		}

		{
			int64 cur = max(a[i0].first + a[i2].first, max(a[i1].first + a[i].first, a[i0].first + a[i1].first + h));
			s[i] = min(s[i], mp(cur, i));
		}
	}

	int64 res = INF64;
	forn(i, n) {
		res = min(res, s[i].first - p[i].first);
		if (res == ANS && print) {
			{
				int j = p[i].second;
				i0 = 0, i1 = 1, i2 = 2;

				if (p[j].first == min(a[i0].first + a[j].first, min(a[i1].first + a[i2].first, a[i0].first + a[i1].first + h))) {
					ans[i0] = 1;
					ans[j] = 1;
				} else if (p[j].first == min(a[i0].first + a[i2].first, min(a[i1].first + a[j].first, a[i0].first + a[i1].first + h))) {
					ans[i1] = 1;
					ans[j] = 1;
				} else
					throw;
			}

			{
				int j = s[i].second;
				i0 = n-1, i1 = n-2, i2 = n-3;

				if (s[j].first == min(a[i0].first + a[j].first, min(a[i1].first + a[i2].first, a[i0].first + a[i1].first + h))) {
					ans[i0] = 1;
					ans[j] = 1;
				} else if (s[j].first == min(a[i0].first + a[i2].first, min(a[i1].first + a[j].first, a[i0].first + a[i1].first + h))) {
					ans[i1] = 1;
					ans[j] = 1;
				} else
					throw;
			}

			printAnswer();
		}
	}

	return res;
}

int main() {
#ifdef NALP_PROJECT
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#else
#endif

	cin >> n >> h;
	forn(i, n) {
		scanf("%I64d", &a[i].first);
		a[i].second = i;
	}

	sort(a, a + n);

	int best = -1;
	int64 ans = INF64;

	{
		int64 cur = solveByMask(false);
		if (cur < ans) {
			ans = cur;
			best = 1;
		}
	}

	{
		int64 cur = solveByCalc(false);
		if (cur < ans) {
			ans = cur;
			best = 2;
		}
	}

	ANS = ans;
	if (best == 1) solveByMask(true);
	if (best == 2) solveByCalc(true);

	return 0;
}


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

    #pragma comment(linker, "/stack:64000000")

    using namespace std;
    typedef long long int i64;
    typedef pair<int, int> pii;

    const int INF = 2000 * 1000 * 1000;
    const i64 LONGINF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
    const int MAXN = 1000 * 1000;
    const int mod = 1000 * 1000 * 1000 + 9;

    int a[100000];
    int main()
        {
            int n, h;
            scanf("%d%d", &n, &h);
            for(int i = 0; i < n; i++)
                scanf("%d", a + i);
            int mini = min_element(a, a + n) - a;
            sort(a, a + n);
            if( abs( max(a[n - 1] + a[n - 2], a[0] + h + a[n - 1]) - min(a[0] + a[1] + h, a[1] + a[2]) )
                   < abs(a[n - 1] + a[n - 2] - a[0] - a[1]) )
            {
                printf("%d\n", abs( max(a[n - 1] + a[n - 2], a[0] + h + a[n - 1]) - min(a[0] + a[1] + h, a[1] + a[2]) ) );
                for(int i = 0; i < n; i++)
                    if(i != mini)
                        printf("1 ");
                    else
                        printf("2 ");
                printf("\n");
            }
            else
            {
                printf("%d\n", abs(a[n - 1] + a[n - 2] - a[0] - a[1]));
                for(int i = 0; i < n; i++)
                    printf("1 ");
                printf("\n");
            }

            return 0;
        }


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

    #pragma comment(linker, "/stack:64000000")

    using namespace std;
    typedef long long int i64;
    typedef pair<int, int> pii;

    const int INF = 2000 * 1000 * 1000;
    const i64 LONGINF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
    const int MAXN = 1000 * 1000;
    const int mod = 1000 * 1000 * 1000 + 9;

    int a[100000];
    int main()
        {
            int n, h;
            scanf("%d%d", &n, &h);
            for(int i = 0; i < n; i++)
                scanf("%d", a + i);
            sort(a, a + n);
            int mini = min_element(a, a + n) - a;
            if( abs(a[n - 1] + a[n - 2] - a[0] - a[1] - h) < abs(a[n - 1] + a[n - 2] - a[0] - a[1]) )
            {
                for(int i = 0; i < n; i++)
                    if(i != mini)
                        printf("1 ");
                    else
                        printf("2 ");
                printf("\n");
            }
            else
            {
                for(int i = 0; i < n; i++)
                    printf("1 ");
                printf("\n");
            }

            return 0;
        }


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

    #pragma comment(linker, "/stack:64000000")

    using namespace std;
    typedef long long int i64;
    typedef pair<int, int> pii;

    const int INF = 2000 * 1000 * 1000;
    const i64 LONGINF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
    const int MAXN = 1000 * 1000;
    const int mod = 1000 * 1000 * 1000 + 9;

    int a[100000];
    int main()
        {
            int n, h;
            scanf("%d%d", &n, &h);
            for(int i = 0; i < n; i++)
                scanf("%d", a + i);
            sort(a, a + n);
            int mini = min_element(a, a + n) - a;
            if( abs( max(a[n - 1] + a[n - 2], a[0] + h + a[n - 1]) - min(a[0] + a[1] + h, a[1] + a[2]) )
                   < abs(a[n - 1] + a[n - 2] - a[0] - a[1]) )
            {
                printf("%d\n", abs( max(a[n - 1] + a[n - 2], a[0] + h + a[n - 1]) - min(a[0] + a[1] + h, a[1] + a[2]) ) );
                for(int i = 0; i < n; i++)
                    if(i != mini)
                        printf("1 ");
                    else
                        printf("2 ");
                printf("\n");
            }
            else
            {
                printf("%d\n", abs(a[n - 1] + a[n - 2] - a[0] - a[1]));
                for(int i = 0; i < n; i++)
                    printf("1 ");
                printf("\n");
            }

            return 0;
        }


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

    #pragma comment(linker, "/stack:64000000")

    using namespace std;
    typedef long long int i64;
    typedef pair<int, int> pii;

    const int INF = 2000 * 1000 * 1000;
    const i64 LONGINF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
    const int MAXN = 1000 * 1000;
    const int mod = 1000 * 1000 * 1000 + 9;

    int a[100000];
    int main()
        {
            int n, h;
            scanf("%d%d", &n, &h);
            for(int i = 0; i < n; i++)
                scanf("%d", a + i);
            sort(a, a + n);
            int mini = min_element(a, a + n) - a;
            if( abs(a[n - 1] + a[n - 2] - a[0] - a[1] - h) < abs(a[n - 1] + a[n - 2] - a[0] - a[1]) )
            {
                printf("%d\n", abs(a[n - 1] + a[n - 2] - a[0] - a[1] - h));
                for(int i = 0; i < n; i++)
                    if(i != mini)
                        printf("1 ");
                    else
                        printf("2 ");
                printf("\n");
            }
            else
            {
                printf("%d\n", abs(a[n - 1] + a[n - 2] - a[0] - a[1]));
                for(int i = 0; i < n; i++)
                    printf("1 ");
                printf("\n");
            }

            return 0;
        }


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>
#include <climits>
#include <cmath>
#include <cassert>
#include <cstdio>

#define debug(var) (cerr << #var << " = " << (var) << endl)
#define debugp(pvar) (cerr << #pvar << " = (" << (pvar).first << ", " << (pvar).second << ")" << endl)

typedef long long i3;
typedef int i2;
typedef short i1;

using namespace std;

i2 main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("log.txt", "w", stderr);
#endif

	int n, h;
	cin >> n >> h;

	if(n == 2)
	{
		cout << "0\n2 2";
	}
	else
	{
		pair<int, int> mino(INT_MAX, -1);
		vector<int> mins(3, INT_MAX), maxs(2, 0);
		for(int l = n, t; l--; )
			cin >> t,
			mins.push_back(t), sort(mins.begin(), mins.end()), mins.pop_back(),
			maxs.push_back(t), sort(maxs.rbegin(), maxs.rend()), maxs.pop_back(),
			mino = min(mino, make_pair(t, n - l - 1));

		int oldmax = maxs[0] + maxs[1];
		int oldmin = mins[0] + mins[1];
		int olddiff = oldmax - oldmin;
		int newmax = max(mins[0] + maxs[0] + h, oldmax);
		int newmin = min(mins[1] + mins[2], oldmin + h);
		int newdiff = newmax - newmin;

		debugp(mino);
		debug(oldmax = maxs[0] + maxs[1]);
		debug(oldmin = mins[0] + mins[1]);
		debug(olddiff = oldmax - oldmin);
		debug(newmax = max(mins[0] + maxs[0] + h, oldmax));
		debug(newmin = min(mins[1] + mins[2], oldmin + h));
		debug(newdiff = newmax - newmin);

		cout << min(newdiff, olddiff) << '\n';

		for(int l = mino.second; l--; )
			cout << "2 ";
		cout << (newdiff < olddiff ? '1' : '2');
		while(--n > mino.second)
			cout << " 2";
	}

}


#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int Min(int a, int b)
{
    return (a > b)?b:a;
}

int Max(int a, int b)
{
    return (a < b)?b:a;
}

int main()
{

    //freopen("input.txt","r",stdin);//////////////////////////////

    int n, h, min1 = INT_MAX, mini, min2 = 0, max, min, min3 = 0;
    cin >> n >> h;
    multiset< int > s;

    for(int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        s.insert(c);
        if(min1 > c)
        {
            min1 = c;
            mini = i;
        }
    }

    multiset< int >::reverse_iterator rit;
    rit = s.rbegin();
    int max1 = *rit;
    int max2 = *(++rit);

    multiset< int >::iterator it;
    it = s.begin();
    min2 = *(++it);
    if( n>2 ) min3 = *(++it);

    min = (n>2)? Min(min2 + min3,(min1 + h) + min2): (min1 + h) + min2;
    max = Max(max1 + max2,max1 + (h + min1));
    bool b = ( max2 + max1 - min1 - min2) >= ( max - min );

    for(int i = 0; i < n; i++)
    {
        if((i == mini)&&(b))
        {
            cout << 2 << ' ';
        }
        else
        {
            cout << 1 << ' ';
        }
    }
}


#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int Min(int a, int b)
{
    return (a > b)?b:a;
}

int Max(int a, int b)
{
    return (a < b)?b:a;
}

int main()
{

    //freopen("input.txt","r",stdin);//////////////////////////////

    int n, h, min1 = INT_MAX, mini, min2 = 0, max, min, min3 = 0;
    cin >> n >> h;
    set< int > s;

    for(int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        s.insert(c);
        if(min1 > c)
        {
            min1 = c;
            mini = i;
        }
    }

    set< int >::reverse_iterator rit;
    rit = s.rbegin();
    int max1 = *rit;
    int max2 = *(++rit);

    set< int >::iterator it;
    it = s.begin();
    min2 = *(++it);
    min3 = *(++it);

    min = Min(min2 + min3,(min1 + h) + min2);
    max = Max(max1 + max2,max1 + (h + min1));
    bool b = ( max2 + max1 - min1 - min2) >= ( max - min );

    for(int i = 0; i < n; i++)
    {
        if((i == mini)&&(b))
        {
            cout << 2 << ' ';
        }
        else
        {
            cout << 1 << ' ';
        }
    }
}


#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int Min(int a, int b)
{
    return (a > b)?b:a;
}

int Max(int a, int b)
{
    return (a < b)?b:a;
}

int main()
{

    //freopen("input.txt","r",stdin);//////////////////////////////

    int n, h, min1 = INT_MAX, mini, min2 = 0, max, min, min3 = 0;
    cin >> n >> h;
    multiset< int > s;

    for(int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        s.insert(c);
        if(min1 > c)
        {
            min1 = c;
            mini = i;
        }
    }

    multiset< int >::reverse_iterator rit;
    rit = s.rbegin();
    int max1 = *rit;
    int max2 = *(++rit);

    multiset< int >::iterator it;
    it = s.begin();
    min2 = *(++it);
    if( n>2 ) min3 = *(++it);

    min = (n>2)? Min(min2 + min3,(min1 + h) + min2): (min1 + h) + min2;
    max = Max(max1 + max2,max1 + (h + min1));
    bool b = ( max2 + max1 - min1 - min2) >= ( max - min );

    if(b)
        cout << max - min << '\n';
    else
        cout << max2 + max1 - min1 - min2 << '\n';

    for(int i = 0; i < n; i++)
    {
        if((i == mini)&&(b))
        {
            cout << 2 << ' ';
        }
        else
        {
            cout << 1 << ' ';
        }
    }
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100005];

int main(){
    int n,h;
    memset(a,0,sizeof(a));
    scanf("%d%d",&n,&h);
    int i,j;
    int minn=0x7fffffff,pos=0,ans;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]<minn){
            minn=a[i];
            pos=i;
        }
    }
    sort(a+1,a+n+1);
    bool f=0;
    if(a[1]+a[2]+h<=a[n-1]+a[n])f=1;
    if(!f)ans=a[n-1]+a[n]-a[1]-a[2];
    else ans=max(a[n-1]+a[n],a[n]+a[1]+h)-min(a[1]+a[2]+h,a[2]+a[3]);
    printf("%d\n",ans);
    if(!f){
        for(i=1;i<=n;i++)printf("1 ");
        printf("\n");
    }
    else{
        for(i=1;i<=n;i++){
            if(i==pos)printf("2 ");
            else printf("1 ");
        }
        printf("\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100005];

int main(){
    int n,h;
    memset(a,0,sizeof(a));
    scanf("%d%d",&n,&h);
    int i,j;
    int minn=0x7fffffff,pos=0,ans;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]<minn){
            minn=a[i];
            pos=i;
        }
    }
    sort(a+1,a+n+1);
    bool f=0;
    int ans1=a[n]+a[n-1]-a[1]-a[2];
    int ans2=max(a[n-1]+a[n],a[n]+a[1]+h)-min(a[1]+a[2]+h,a[2]+a[3]);
    if(ans1<ans2){
        ans=ans1;
    }
    else{
        ans=ans2;
        f=1;
    }
    printf("%d\n",ans);
    if(!f){
        for(i=1;i<=n;i++)printf("1 ");
        printf("\n");
    }
    else{
        for(i=1;i<=n;i++){
            if(i==pos)printf("2 ");
            else printf("1 ");
        }
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory.h>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <utility>
#include <bitset>
#include <cassert>
#include <climits>
#include <functional>

using namespace std;

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ppb pop_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;

int main() {
    int n, h;
    cin >> n >> h;
    vi a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int minIndex = min_element(all(a)) - a.begin();
    sort(all(a));
    int f1 = (a[n - 1] + a[n - 2]) - (a[1] + a[0]);
    a[0] += h;
    sort(all(a));
    int f2 = (a[n - 1] + a[n - 2]) - (a[1] + a[0]);
    if (f1 < f2) {
        cout << f1 << endl;
        for (int i = 0; i < n; i++) {
            cout << 1 << " \n"[i == n - 1];
        }
    }
    else {
        cout << f2 << endl;
        for (int i = 0; i < n; i++) {
            if (i == minIndex)
                cout << 2 << " \n"[i == n - 1];
            else
                cout << 1 << " \n"[i == n - 1];
        }
    }
    return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
using namespace std;

int main()
{
vector <int> ans;
vector <pair<int,int> > a;
int n,h;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
scanf("%d%d",&n,&h);
a.resize(n);
ans.resize(n,1);
for (int i=0; i<n; i++) {
    scanf("%d",&a[i].first);
    a[i].second=i;
}
sort(a.begin(),a.end());
int id=a[n-1].first+a[n-2].first-a[0].first-a[1].first,fn=max(a[0].first+a[n-1].first+h,a[n-1].first+a[n-2].first)-min(a[1].first+a[2].first,a[0].first+a[1].first+h);
if (id>fn) {
    ans[a[0].second]=2;
    printf("%d\n",fn);
}
else printf("%d\n",id);
for (int i=0; i<n; i++)printf("%d ",ans[i]);
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
using namespace std;

int main()
{
vector <int> ans;
vector <pair<int,int> > a;
int n,h;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
scanf("%d%d",&n,&h);
a.resize(n);
ans.resize(n,1);
for (int i=0; i<n; i++) {
    scanf("%d",&a[i].first);
    a[i].second=i;
}
if (n==2) {puts("0"); puts("1 1"); return 0; }
sort(a.begin(),a.end());
int id=a[n-1].first+a[n-2].first-a[0].first-a[1].first;
int fn=max(a[0].first+a[n-1].first+h,a[n-1].first+a[n-2].first)-min(a[1].first+a[2].first,a[0].first+a[1].first+h);
if (id>fn) {
    ans[a[0].second]=2;
    printf("%d\n",fn);
}
else printf("%d\n",id);
for (int i=0; i<n; i++)printf("%d ",ans[i]);
return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-8
#define maxm 200000000
#define MAXN 33
#define inf 1000000000
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  100010;
#define mod  1000000009
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int a[100002];
int main() {
     //freopen("E:\\in.txt","r",stdin);
     //freopen("E:\\out.txt","w",stdout);
   int n,m;
   while(scanf("%d%d",&n,&m)!=EOF)
   {
     int i;
     for (i=0;i<n;i++)
     {
         scanf("%d",&a[i]);
     }
     sort(a,a+n);
     int ans1,ans2;
     if(n==2) ans1=0;
     else
     {
          ans1=a[n-1]+a[n-2]-a[0]-a[1];
     }
     int f[10];
     if(n==2) ans2=0;
     else if(n==3)
     {
          f[0]=a[0]+a[1]+m;
          f[1]=a[1]+a[2];
          f[2]=a[0]+a[2]+m;
          sort(f,f+3);
          ans2=f[2]-f[1];
     }
     else
     {
          f[0]=a[1]+a[2];
          f[1]=a[0]+a[1]+m;
          f[2]=a[n-1]+a[n-2];
          f[3]=a[0]+a[n-1]+m;
          sort(f,f+4);
          ans2=f[3]-f[1];
     }
     if(ans1<=ans2)
     {
         printf("%d\n",ans1);
         for (i=0;i<n;i++)
         {
             if(i) printf(" ");
             printf("%d",1);
         }
     }
     else
     {
          printf("%d\n",ans2);
          printf("2");
          for (i=1;i<n;i++)
          {
              printf(" %d",1);
          }
     }
     printf("\n");
   }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-8
#define maxm 200000000
#define MAXN 33
#define inf 1000000000
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  100010;
#define mod  1000000009
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int a[100002];
int main() {
     //freopen("E:\\in.txt","r",stdin);
     //freopen("E:\\out.txt","w",stdout);
   int n,m;
   while(scanf("%d%d",&n,&m)!=EOF)
   {
     int i;
     int mx=inf;
     int id;
     for (i=0;i<n;i++)
     {
         scanf("%d",&a[i]);
         if(a[i]<mx)
         {
             mx=a[i];
             id=i;
         }
     }
     sort(a,a+n);
     int ans1,ans2;
     if(n==2) ans1=0;
     else
     {
          ans1=a[n-1]+a[n-2]-a[0]-a[1];
     }
     int f[10];
     if(n==2) ans2=0;
     else if(n==3)
     {
          f[0]=a[0]+a[1]+m;
          f[1]=a[1]+a[2];
          f[2]=a[0]+a[2]+m;
          sort(f,f+3);
          ans2=f[2]-f[0];
     }
     else
     {
          f[0]=a[1]+a[2];
          f[1]=a[0]+a[1]+m;
          f[2]=a[n-1]+a[n-2];
          f[3]=a[0]+a[n-1]+m;
          sort(f,f+4);
          ans2=f[3]-f[0];
     }
     if(ans1<=ans2)
     {
         printf("%d\n",ans1);
         for (i=0;i<n;i++)
         {
             if(i) printf(" ");
             printf("%d",1);
         }
     }
     else
     {
          printf("%d\n",ans2);
          for (i=0;i<n;i++)
          {
             if(i) printf(" ");
             if(i==id) printf("1");
             else printf("2");
          }
     }
     printf("\n");
   }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-8
#define maxm 200000000
#define MAXN 33
#define inf 1000000000
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  100010;
#define mod  1000000009
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int a[100002];
int main() {
     //freopen("E:\\in.txt","r",stdin);
     //freopen("E:\\out.txt","w",stdout);
   int n,m;
   while(scanf("%d%d",&n,&m)!=EOF)
   {
     int i;
     for (i=0;i<n;i++)
     {
         scanf("%d",&a[i]);
     }
     sort(a,a+n);
     int ans1,ans2;
     if(n==2) ans1=0;
     else
     {
          ans1=a[n-1]+a[n-2]-a[0]-a[1];
     }
     int f[10];
     if(n==2) ans2=0;
     else if(n==3)
     {
          f[0]=a[0]+a[1]+m;
          f[1]=a[1]+a[2];
          f[2]=a[0]+a[2]+m;
          sort(f,f+3);
          ans2=f[2]-f[0];
     }
     else
     {
          f[0]=a[1]+a[2];
          f[1]=a[0]+a[1]+m;
          f[2]=a[n-1]+a[n-2];
          f[3]=a[0]+a[n-1]+m;
          sort(f,f+4);
          ans2=f[3]-f[0];
     }
     if(ans1<=ans2)
     {
         printf("%d\n",ans1);
         for (i=0;i<n;i++)
         {
             if(i) printf(" ");
             printf("%d",1);
         }
     }
     else
     {
          printf("%d\n",ans2);
          printf("2");
          for (i=1;i<n;i++)
          {
              printf(" %d",1);
          }
     }
     printf("\n");
   }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-8
#define maxm 200000000
#define MAXN 33
#define inf 1000000000
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  100010;
#define mod  1000000009
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int a[100002];
int main() {
     //freopen("E:\\in.txt","r",stdin);
     //freopen("E:\\out.txt","w",stdout);
   int n,m;
   while(scanf("%d%d",&n,&m)!=EOF)
   {
     int i;
     for (i=0;i<n;i++)
     {
         scanf("%d",&a[i]);
     }
     sort(a,a+n);
     int ans1,ans2;
     if(n==2) ans1=0;
     else
     {
          ans1=a[n-1]+a[n-2]-a[0]-a[1];
     }
     int f[10];
     if(n==2) ans2=0;
     else if(n==3)
     {
          f[0]=a[0]+a[1]+m;
          f[1]=a[1]+a[2];
          f[2]=a[0]+a[2]+m;
          sort(f,f+3);
          ans2=f[2]-f[0];
     }
     else
     {
          f[0]=a[1]+a[2];
          f[1]=a[0]+a[1]+m;
          f[2]=a[n-1]+a[n-2];
          f[3]=a[0]+a[n-1]+m;
          sort(f,f+4);
          ans2=f[3]-f[0];
     }
     if(ans1<=ans2)
     {
         printf("%d\n",ans1);
         for (i=0;i<n;i++)
         {
             if(i) printf(" ");
             printf("%d",1);
         }
     }
     else
     {
          printf("%d\n",ans2);
          printf("1");
          for (i=1;i<n;i++)
          {
              printf(" %d",2);
          }
     }
     printf("\n");
   }
   return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
long n,h,r,rh;
scanf("%d %d",&n,&h);
vector <pair <long,long> > v;
v.resize(n);
for (int i=0;i<n;i++) {scanf("%d",&v[i].first);v[i].second=i;}
sort(v.begin(),v.end());
if (n==2) {printf("0\n1 1");return 0;}
r=v[n-1].first+v[n-2].first-(v[1].first+v[0].first);
rh=max(v[n-1].first+v[n-2].first,v[n-1].first+v[0].first+h)-min(v[1].first+v[0].first+h,v[2].first+v[1].first);
if (r<rh)
{
	printf("%d\n",r);
	for (long i=0;i<n;i++) printf("1 ");
}
else
{
	printf("%d\n",rh);
	for (long i=0;i<n;i++) if (v[i].second==0) printf("2 "); else printf("1 ");
}
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
long n,h,r,rh;
scanf("%d %d",&n,&h);
vector <pair <long,long> > v;
v.resize(n);
for (long i=0;i<n;i++) {scanf("%d",&v[i].first);v[i].second=i;}
sort(v.begin(),v.end());
if (n==2) {printf("0\n1 1");return 0;}
r=v[n-1].first+v[n-2].first-(v[1].first+v[0].first);
rh=max(v[n-1].first+v[n-2].first,v[n-1].first+v[0].first+h)-min(v[1].first+v[0].first+h,v[2].first+v[1].first);
if (r<=rh)
{
	printf("%d\n",r);
	for (long i=0;i<n;i++) printf("1 ");
}
else
{
	printf("%d\n",rh);
	for (long i=0;i<n;i++) if (i==v[0].second) printf("1 "); else printf("2 ");
}
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n,h,r,rh;
scanf("%d %d",&n,&h);
vector <pair <int,int> > v;
v.resize(n);
for (int i=0;i<n;i++) {scanf("%d",&v[i].first);v[i].second=i;}
sort(v.begin(),v.end());
if (n==2) {printf("0\n1 1");return 0;}
r=v[n-1].first+v[n-2].first-(v[1].first+v[0].first);
rh=max(v[n-1].first+v[n-2].first,v[n-1].first+v[0].first+h)-min(v[1].first+v[0].first+h,v[2].first+v[1].first);
if (r<=rh)
{
	printf("%d\n",r);
	for (int i=0;i<n;i++) printf("1 ");
}
else
{
	printf("%d\n",rh);
	for (int i=0;i<n;i++) if (v[i].second!=0) printf("1 "); else printf("2 ");
}
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
long n,h,r,rh;
scanf("%d %d",&n,&h);
vector <pair <long,long> > v;
v.resize(n);
for (int i=0;i<n;i++) {scanf("%d",&v[i].first);v[i].second=i;}
sort(v.begin(),v.end());
if (n==2) {printf("0\n1 1");return 0;}
r=v[n-1].first+v[n-2].first-(v[1].first+v[0].first);
rh=max(v[n-1].first+v[n-2].first,v[n-1].first+v[0].first+h)-min(v[1].first+v[0].first+h,v[2].first+v[1].first);
if (r<=rh)
{
	printf("%d\n",r);
	for (long i=0;i<n;i++) printf("1 ");
}
else
{
	printf("%d\n",rh);
	for (long i=0;i<n;i++) if (v[i].second==0) printf("2 "); else printf("1 ");
}
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
long n,h,r,rh;
scanf("%d %d",&n,&h);
vector <pair <long,long> > v;
v.resize(n);
for (long i=0;i<n;i++) {scanf("%d",&v[i].first);v[i].second=i;}
sort(v.begin(),v.end());
if (n==2) {printf("0\n1 1");return 0;}
r=v[n-1].first+v[n-2].first-(v[1].first+v[0].first);
rh=max(v[n-1].first+v[n-2].first,v[n-1].first+v[0].first+h)-min(v[1].first+v[0].first+h,v[2].first+v[1].first);
if (r<=rh)
{
	printf("%d\n",r);
	for (long i=0;i<n;i++) printf("1 ");
}
else
{
	printf("%d\n",rh);
	for (long i=0;i<n;i++) if (i==v[i].second) printf("1 "); else printf("2 ");
}
return 0;
}


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

using namespace std;

typedef long long Int;
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define sz(s) (int)s.size()
#define pb push_back
#define mp make_pair
#define sqr(x) (x)*(x)
const int inf = 1000000000;
const int MOD = 1000000007;

int a[100001];
pair<int,int>g[100001];
int res[100001];

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,h;
	cin>>n>>h;
	FOR(i,1,n)cin>>a[i],g[i]=mp(a[i],i);
	sort(g+1,g+n+1);
	sort(a+1,a+n+1);

	memset(res,0,sizeof(res));
	Int ans = inf;
	int will;
	FOR(i,1,n)
	{
		int mn=inf,mx=-inf;
		//mn:
		if(i>=2)mn=min(a[1]+a[2],mn);
		if(i+2<=n)mn=min(a[i+1]+a[i+2],mn);
		if(i>=1 && i<n)mn=min(mn,a[1]+a[i+1]+h);

		//mx:
		if(i>=2)mx=max(a[i]+a[i-1],mx);
		if(i+2<=n)mx=max(a[n]+a[n-1],mx);
		if(i>=1 && i<n)mx=max(mx,a[i]+a[n]+h);

		if(mx-mn<ans)
		{
			ans=mx-mn;
			will = i;
		}
	}

	FOR(i,1,will)res[g[i].second]=1;
	FOR(i,will+1,n)res[g[i].second]=2;

	cout<<ans<<endl;
	FOR(i,1,n)cout<<res[i]<<" ";cout<<endl;
}


#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define eps 1e-9
#define VI vectir<int>
#define MP make_pair
#define f0(i,n) for (i = 0; i < n; i++)

int n , i , h , a[100000] , x , col[100000];
pair<int,int> b[100000];

int main()
{
    cin>>n>>h;
    for (i = 0; i < n; i++)
    {
        cin>>b[i].first;
        b[i].second = i;
    }

    sort (b , b + n);

    if (n == 2)
    {
        cout<<0<<endl;
        cout<<1<<" "<<2<<endl;
        return 0;
    }

    int ansdif = b[n-1].first + b[n-2].first - ( b[0].first + b[1].first );

    int ansnew =  max(b[n-1].first + b[n-2].first , b[n-1].first + b[0].first + h)  -  min(b[0].first + b[1].first + h , b[1].first + b[2].first);

    if (ansdif > ansnew)
    {
        cout<<ansnew<<endl;
        f0(i,n)
        {
            if (i == b[0].second)
                cout<<1<<" ";
            else
                cout<<2<<" ";
        }
    } else
    {
        cout<<ansdif<<endl;
        f0(i , n) cout<<2<<" ";
    }

    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define eps 1e-9
#define VI vectir<int>
#define MP make_pair
#define f0(i,n) for (i = 0; i < n; i++)

int n , i , h , a[100000] , x , col[100000];
pair<int,int> b[100000];

int main()
{
    cin>>n>>h;
    for (i = 0; i < n; i++)
    {
        cin>>b[i].first;
        b[i].second = i;
    }

    sort (b , b + n);

    if (n == 2)
    {
        cout<<1<<" "<<2<<endl;
        return 0;
    }

    int ansdif = b[n-1].first + b[n-2].first - ( b[0].first + b[1].first );

    int ansnew =  max(b[n-1].first + b[n-2].first , b[n-1].first + b[0].first + h)  -  min(b[0].first + b[1].first + h , b[1].first + b[2].first);

    if (ansdif > ansnew)
    {
        cout<<ansnew<<endl;
        f0(i,n)
        {
            if (i == b[0].second)
                cout<<1<<" ";
            else
                cout<<2<<" ";
        }
    } else
    {
        cout<<ansdif<<endl;
        f0(i , n) cout<<2<<" ";
    }

    return 0;
}


def finddiff(A, other, h):
  max1 = A[-1] + A[-2]
  min1 = A[0]+ A[1]
  min2 = other + A[0] + h
  max2 = other + A[-1] + h
  return max(max1,max2) - min(min1,min2)
n, h = map(int, raw_input().split())
numbers = map(int, raw_input().split())
savenum = -1
num = numbers[:]
numbers.sort()
min1 = numbers[-1]+numbers[-2]-numbers[0]-numbers[1]
if n > 2:
  for i in [0,1,2,-1,-2,-3]:
    minp = finddiff( numbers[:i] + numbers[i+1:], numbers[i], h)
    #print numbers[:i] + numbers[i+1:], numbers[i], minp
    if minp < min1:
      savenum = numbers[i]
      min1 = minp
print min1
one = False
for i in range(n):
  if num[i] == savenum and not one:
    print 2,
    one = True
  else:
    print 1,


def finddiff(A, other, h):
  max1 = A[-1] + A[-2]
  min1 = A[0]+ A[1]
  min2 = other + A[0] + h
  max2 = other + A[-1] + h
  return max(max1,max2) - min(min1,min2)
n, h = map(int, raw_input().split())
numbers = map(int, raw_input().split())
savenum = -1
num = numbers[:]
numbers.sort()
min1 = numbers[-1]+numbers[-2]-numbers[0]-numbers[1]
if n > 2:
  for i in range(n):
    minp = finddiff( numbers[:i] + numbers[i+1:], numbers[i], h)
    #print numbers[:i] + numbers[i+1:], numbers[i], minp
    if minp < min1:
      savenum = numbers[i]
      min1 = minp
print min1
one = False
for i in range(n):
  if num[i] == savenum and not one:
    print 2,
    one = True
  else:
    print 1,


def finddiff(A, other, h):
  A.sort()
  max1 = A[-1] + A[-2]
  min1 = A[0]+ A[1]
  min2 = other + A[0] + h
  max2 = other + A[-1] + h
  return max(max1,max2) - min(min1,min2)
n, h = map(int, raw_input().split())
numbers = map(int, raw_input().split())
savei=-1
num = numbers[:]
num.sort()
min1 = num[-1]+num[-2]-num[0]-num[1]
if n > 2:
  for i in range(n):
    minp = finddiff( numbers[i+1:] + numbers[:i], numbers[i], h)
    if minp < min1:
      savei = i
      min1 = minp
print min1
for i in range(n):
  if i == savei:
    print 2,
  else:
    print 1,


from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
n, m = rints()
a = sorted(rints())

if n == 2:
    print('%d\n%s' % (0, '1 1'))
else:
    diff1 = (a[-1] + a[-2]) - (a[0] + a[1])
    diff2 = max(a[-1] + a[-2], a[-1] + a[0] + m) - min(a[0] + a[1] + m, a[1] + a[2])
    ans = ['1'] * n if diff2 >= diff1 else ['2'] + ['1'] * (n - 1)

    print('%d\n%s' % (min(diff2, diff1), ' '.join(ans)))


from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
n, m = rints()
a = rints()
mi = a.index(min(a))

if n == 2:
    print('%d\n%s' % (0, '1 1'))
else:
    a.sort()
    ans = ['1'] * n
    diff1 = (a[-1] + a[-2]) - (a[0] + a[1])
    diff2 = max(a[-1] + a[-2], a[-1] + a[0] + m) - min(a[0] + a[1] + m, a[1] + a[2])
    if diff2 < diff1:
        ans[mi] = '2'

    print('%d\n%s' % (min(diff2, diff1), ' '.join(ans)))


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX];
inline void read(){
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)numbers[i]=fastIn<int>();
}
inline int solve1(){
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2(){
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int a=numbers[0]+numbers[1]+k;
    int b=numbers[0]+numbers[number_count-1]+k;
    int c=numbers[1]+numbers[2];
    int d=numbers[number_count-1]+numbers[number_count-2];
    int mn=min(a,min(b,min(c,d)));
    int mx=max(a,max(b,max(c,d)));
    return mx-mn;
}
inline void proc(){
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ){
        puts("0\n1 1");
    }else{
        int a=solve1(),b=solve2();
        if(a<b){
            cout<<a<<'\n';
            fo(i,number_count)cout<<1<<' ';
            line;
        }else{
            cout<<b<<'\n';
            cout<<1<<' ';
            foR(i,1,number_count)cout<<2<<' ';
            line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX],ai[MX];
inline void read() {
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)
        ai[i]=numbers[i]=fastIn<int>();
}
inline int solve1() {
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2() {
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int n=number_count;
    int mn=min(numbers[0]+numbers[1]+k, numbers[1]+numbers[2]);
    int mx=max(numbers[0]+numbers[n-1]+k,numbers[n-1]+numbers[n-2]);
    return abs(mx-mn);
}
inline void proc() {
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ) {
        puts("0\n1 1");
    } else {
        int a=solve1(),b=solve2();
        cout<<min(a,b)<<'\n';
        if(a<=b){
            fo(i,number_count)cout<<1<<' ';
            line;
        }else{
            bool prothom=true;
            fo(i,number_count){
                if(ai[i]==numbers[0]&&prothom){
                    cout<<1<<' ';
                    prothom=false;
                }
                else cout<<2<<' ';
            }line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
int number_count;
struct node {
    int n;
    int i;
};
bool operator<(const node &l, const node &r) {
    return l.n<r.n;
}
inline ostream& operator<< (ostream &out, const node &r) {
    out<<r.n<<' '<<r.i;
}
const int MX = (int)1e5+5;
int K;
node numbers[MX];
inline void read() {
    number_count=fastIn<int>(),K=fastIn<int>();
    fo(i,number_count) {
        numbers[i]=node {fastIn<int>(), i};
    }
    sort(numbers,numbers+number_count);
}
const int inf=1203456789;
inline int solve1() {
    int a=max(numbers[0].n+numbers[number_count-1].n+K, numbers[number_count-1].n+numbers[number_count-2].n);
    int b=min(numbers[0].n+numbers[1].n+K, numbers[1].n+numbers[2].n);
    return abs(a-b);
}
inline int solve2(){
    return abs( (numbers[0].n+numbers[1].n) - (numbers[number_count-1].n+numbers[number_count-2].n) );
}
inline void proc() {
//    fo(i,number_count)cout<<numbers[i]<<'\n';
//    line;
    if(number_count==2) {
        cout<<1<<' '<<1<<'\n';
        return ;
    }
    int a=solve1(),b=solve2();
    if( a<b ){
        cout<<a<<'\n';
        cout<<1<<' ';
        foR(i,1,number_count)cout<<2<<' ';
        line;
    }
    else{
        cout<<b<<'\n';
        fo(i,number_count)cout<<1<<' ';
        line;
    }

}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
int number_count;
struct node {
    int n;
    int i;
};
bool operator<(const node &l, const node &r) {
    return l.n<r.n;
}
inline ostream& operator<< (ostream &out, const node &r) {
    out<<r.n<<' '<<r.i;
}
const int MX = (int)1e5+5;
int K;
node numbers[MX];
inline void read() {
    number_count=fastIn<int>(),K=fastIn<int>();
    fo(i,number_count) {
        numbers[i]=node {fastIn<int>(), i};
    }
    sort(numbers,numbers+number_count);
}
const int inf=1203456789;
inline int solve1() {
    int a=max(numbers[0].n+numbers[number_count-1].n+K, numbers[number_count-1].n+numbers[number_count-2].n);
    int b=min(numbers[0].n+numbers[1].n+K, numbers[1].n+numbers[2].n);
    return abs(a-b);
}
inline int solve2(){
    return abs( (numbers[0].n+numbers[1].n) - (numbers[number_count-1].n+numbers[number_count-2].n) );
}
inline void proc() {
//    fo(i,number_count)cout<<numbers[i]<<'\n';
//    line;
    if(number_count==2) {
        cout<<0<<'\n';
        cout<<1<<' '<<1<<'\n';
        return ;
    }
    int a=solve1(),b=solve2();
    if( a<b ){
        cout<<a<<'\n';
        cout<<1<<' ';
        foR(i,1,number_count)cout<<2<<' ';
        line;
    }
    else{
        cout<<b<<'\n';
        fo(i,number_count)cout<<1<<' ';
        line;
    }

}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX];
inline void read() {
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)numbers[i]=fastIn<int>();
}
inline int solve1() {
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2() {
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int n=number_count;
    int mn=min(numbers[0]+numbers[1]+k, numbers[1]+numbers[2]);
    int mx=max(numbers[0]+numbers[n-1]+k,numbers[n-1]+numbers[n-2]);
    return abs(mx-mn);
}
inline void proc() {
    int prothom=numbers[0];
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ) {
        puts("0\n1 1");
    } else {
        int a=solve1(),b=solve2();
        int res=min(a,b);
        cout<<res<<"\n";
        if(res==a){
            fo(i,number_count)cout<<1<<' ';
            line;
        }else{
            fo(i,number_count){
                if(prothom==numbers[i])cout<<1<<' ',prothom=-1;
                else cout<<2<<' ';
            }line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX];
inline void read() {
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)numbers[i]=fastIn<int>();
}
inline int solve1() {
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2() {
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int a=numbers[0]+numbers[1]+k;
    int b=numbers[0]+numbers[number_count-1]+k;
    int c=numbers[1]+numbers[2];
    int d=numbers[number_count-1]+numbers[number_count-2];
    int mn=min(a,min(b,min(c,d)));
    int mx=max(a,max(b,max(c,d)));
    return mx-mn;
}
inline void proc() {
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ) {
        puts("0\n1 1");
    } else {
        int a=solve1(),b=solve2();
        if(a<=b) {
            cout<<a<<'\n';
            fo(i,number_count)cout<<1<<' ';
            line;
        } else {
            cout<<b<<'\n';
            cout<<1<<' ';
            foR(i,1,number_count)cout<<2<<' ';
            line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX];
inline void read() {
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)numbers[i]=fastIn<int>();
}
inline int solve1() {
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2() {
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int n=number_count;
    int mn=min(numbers[0]+numbers[1]+k, numbers[1]+numbers[2]);
    int mx=max(numbers[0]+numbers[n-1]+k,numbers[n-1]+numbers[n-2]);
    return abs(mx-mn);
}
inline void proc() {
    int prothom=numbers[0];
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ) {
        puts("0\n1 1");
    } else {
        int a=solve1(),b=solve2();
        int res=min(a,b);
        cout<<res<<"\n";
        if(res==a){
            fo(i,number_count)cout<<1<<' ';
            line;
        }else{
            fo(i,number_count){
                if(prothom==numbers[0])cout<<1<<' ',prothom=-1;
                else cout<<2<<' ';
            }line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=(int)1e5+5;
int number_count,k;
int numbers[MX];
inline void read(){
    number_count=fastIn<int>(),k=fastIn<int>();
    fo(i,number_count)numbers[i]=fastIn<int>();
}
inline int solve1(){
    //sob gula'ke ak bucket'a
    int a= numbers[0]+numbers[1];
    int b= numbers[number_count-1]+numbers[number_count-2];
    return abs(a-b);
}
inline int solve2(){
    //prothom'ta ke first bucket'a
    //second and baki gula'ke onno bucket'a
    int ar[4];
    ar[0]=numbers[0]+numbers[number_count-1]+k;
    ar[1]=numbers[0]+numbers[1]+k;
    ar[2]=numbers[1]+numbers[2];
    ar[3]=numbers[number_count-1]+numbers[number_count-2];
    sort(ar,ar+4);
    return ar[3]-ar[0];
}
inline void proc(){
    sort(numbers,numbers+number_count,less<int>());
    if( number_count==2 ){
        puts("0\n1 1");
    }else{
        int a=solve1(),b=solve2();
        if(a<b){
            cout<<a<<'\n';
            fo(i,number_count)cout<<1<<' ';
            line;
        }else{
            cout<<b<<'\n';
            cout<<1<<' ';
            foR(i,1,number_count)cout<<2<<' ';
            line;
        }
    }
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
int number_count;
struct node {
    int n;
    int i;
};
bool operator<(const node &l, const node &r) {
    return l.n<r.n;
}
inline ostream& operator<< (ostream &out, const node &r) {
    out<<r.n<<' '<<r.i;
}
const int MX = (int)1e5+5;
int K;
node numbers[MX];
inline void read() {
    number_count=fastIn<int>(),K=fastIn<int>();
    fo(i,number_count) {
        numbers[i]=node {fastIn<int>(), i};
    }
    sort(numbers,numbers+number_count);
}
const int inf=1203456789;
int pos[MX];
bool marked[MX];
int xxm,xxM;
inline int get(int a, int b,int n, int k1, int k2) {
    int x1=a+n+k1,x2=b+n+k2;
    int p1=abs(x1-x2);
    int p2=abs(xxm-x1);
    int p3=abs(xxm-x2);
    int p4=abs(xxM-x1);
    int p5=abs(xxM-x2);
    return max(p1, max(p2, max(p3,max(p4,p5)) ) );
}
inline int solve1() {
    SET(pos,0);
    SET(marked,false);
    //put first one in one
    int O1m,O1M,O2m,O2M;
    O1m=O1M=numbers[0].n;
    O2m=O2M=numbers[number_count-1].n;
    xxm=xxM=O1m+O2m+K;
    pos[numbers[0].i]=1,pos[numbers[number_count-1].i]=2;
    marked[0]=marked[number_count-1]=true;

    int bst=0;
    for(int i=1; i+1<number_count; ++i) {
        //prothom tay number ta jog kore dekhbo
        int x1=get(O1m,O2M,numbers[i].n,0,K);
        int x2=get(O1M,O2m,numbers[i].n,0,K);
        int x3=get(O1M,O2M,numbers[i].n,0,K);
        int x4=get(O1m,O2m,numbers[i].n,0,K);
        int mx=max(x1,max(x2,max(x3,x4)));
        //cout<<i<<' '<<mx<<' ';
        //----------------------------------------------------
        //second tay number ta jog kore dekhbo
        int y1=get(O1m,O2M,numbers[i].n,K,0);
        int y2=get(O1M,O2m,numbers[i].n,K,0);
        int y3=get(O1M,O2M,numbers[i].n,K,0);
        int y4=get(O1m,O2m,numbers[i].n,K,0);
        int my=max(y1,max(y2,max(y3,y4)));
        //cout<<my<<'\n';
        bst=max(bst,min(mx,my));
        if(mx<my){
            O1m=min(O1m, numbers[i].n),O1M=max(O1M,numbers[i].n);
            pos[numbers[i].i]=1;
        }else{
            O2m=min(O2m, numbers[i].n),O2M=max(O2M,numbers[i].n);
            pos[numbers[i].i]=2;
        }
    }
    return bst;
}
inline int solve2(){
    return abs( (numbers[0].n+numbers[1].n) - (numbers[number_count-1].n+numbers[number_count-2].n) );
}
inline void proc() {
//    fo(i,number_count)cout<<numbers[i]<<'\n';
//    line;
    if(number_count==2) {
        cout<<1<<' '<<1<<'\n';
        return ;
    }
    int a=solve1(),b=solve2();
    if( a<b ){
        cout<<a<<'\n';
        fo(i,number_count)cout<<pos[i]<<' ';
        line;
    }
    else{
        cout<<b<<'\n';
        fo(i,number_count)cout<<1<<' ';
        line;
    }

}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-01-00.14.48 Saturday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
int number_count;
struct node {
    int n;
    int i;
};
bool operator<(const node &l, const node &r) {
    return l.n<r.n;
}
inline ostream& operator<< (ostream &out, const node &r) {
    out<<r.n<<' '<<r.i;
}
const int MX = (int)1e5+5;
int K;
node numbers[MX];
inline void read() {
    number_count=fastIn<int>(),K=fastIn<int>();
    fo(i,number_count) {
        numbers[i]=node {fastIn<int>(), i};
    }
    sort(numbers,numbers+number_count);
}
const int inf=1203456789;
inline int solve1() {
    int a=numbers[0].n+numbers[number_count-1].n+K;
    int b=numbers[0].n+numbers[1].n+K;
    int c=numbers[1].n+numbers[2].n;
    int d=numbers[number_count-1].n+numbers[number_count-2].n;
    int mn=min(a,min(b,min(c,d)));
    int mx=max(a,max(b,max(c,d)));
    return mx-mn;;
}
inline int solve2(){
    return abs( (numbers[0].n+numbers[1].n) - (numbers[number_count-1].n+numbers[number_count-2].n) );
}
inline void proc() {
//    fo(i,number_count)cout<<numbers[i]<<'\n';
//    line;
    if(number_count==2) {
        cout<<0<<'\n';
        cout<<1<<' '<<1<<'\n';
        return ;
    }
    int a=solve1(),b=solve2();
    if( a<b ){
        cout<<a<<'\n';
        cout<<1<<' ';
        foR(i,1,number_count)cout<<2<<' ';
        line;
    }
    else{
        cout<<b<<'\n';
        fo(i,number_count)cout<<1<<' ';
        line;
    }

}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    int n, h, worst = 0;
    cin >> n >> h;
    int A[n];

    if (n == 2)
    {
        cout << 0 << endl;
        cout << "1 1" << endl;
        return 0;
    }

    for (int i = 0; i < n; i++)
    {
        cin >> A[i];

        if (A[i] < A[worst])
            worst = i;
    }
    sort(A, A + n);
    int B[4] = {A[n - 1] + A[n - 2], A[n - 1] + A[0] + h, A[0] + A[1] + h, A[1] + A[2]};
    sort(B, B + 4);

    int max1 = B[3] - B[0];
    int max2 = abs(A[n - 1] + A[n - 2] - A[0] - A[1]);

    if (max1 < max2)
    {
        cout << max1 << endl;

        for (int i = 0; i < worst; i++)
            cout << 1 << " ";
        cout << 2 << " ";

        for (int i = worst + 1; i < n; i++)
            cout << 1 << " ";
        cout << endl;
    }
    else
    {
        cout << max2 << endl;

        for (int i = 0; i < n; i++)
            cout << 1 << " ";
        cout << endl;
    }
    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define out(x) cout << (x);
typedef long double ld;
template <class _T> inline _T sqr(const _T& x) { return x * x; }
template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-8;
char TEMPORARY_CHAR;
typedef long long ll;
typedef unsigned long long u64;
typedef set < int > SI;
typedef vector < int > VI;
typedef vector < vector < int > > VVI;
typedef map < string, int > MSI;
typedef pair < int, int > PII;
const ll INF = 1e17;
const int N = 1 << 17;
inline void input(int &a)
{
    a = 0;
    while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){}
    char neg = 0;
    if (TEMPORARY_CHAR == '-')
    {
        neg = 1;
        TEMPORARY_CHAR = getchar();
    }
    while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0')
    {
        a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
        TEMPORARY_CHAR = getchar();
    }
    if (neg)
        a = -a;
}
inline int nxt() {in(ret); return ret;}

#define x first
#define y second

#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)

#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))

int main()
{
    in(n); in(h);
    int a[n];
    int min_pos = 0;
    forn(i, n)
    {
        a[i] = nxt();
        if (a[i] < a[min_pos])
            min_pos = i;
    }
    sort(a, a + n);
    if (n == 2)
    {
        cout << "0" << endl;
        cout << "1 1" << endl;
        return 0;
    }
    int mi1 = min(a[0] + a[1] + h, a[1] + a[2]);
    int mi2 = a[0] + a[1];
    int ma1 = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int ma2 = a[n - 1] + a[n - 2];
    if (ma1 - mi1 < ma2 - mi2)
    {
        cout << ma1 - mi1 << endl;
        forn(i, n)
        {
            if (i == min_pos)
                cout << "1 ";
            else
                cout << "2 ";
        }
        return 0;
    }
    cout << ma2 - mi2 << endl;
    forn(i, n)
    {
        cout << "1 ";
    }

    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define out(x) cout << (x);
typedef long double ld;
template <class _T> inline _T sqr(const _T& x) { return x * x; }
template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-8;
char TEMPORARY_CHAR;
typedef long long ll;
typedef unsigned long long u64;
typedef set < int > SI;
typedef vector < int > VI;
typedef vector < vector < int > > VVI;
typedef map < string, int > MSI;
typedef pair < int, int > PII;
const ll INF = 1e17;
const int N = 1 << 17;
inline void input(int &a)
{
    a = 0;
    while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){}
    char neg = 0;
    if (TEMPORARY_CHAR == '-')
    {
        neg = 1;
        TEMPORARY_CHAR = getchar();
    }
    while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0')
    {
        a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
        TEMPORARY_CHAR = getchar();
    }
    if (neg)
        a = -a;
}
inline int nxt() {in(ret); return ret;}

#define x first
#define y second

#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)

#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))

int main()
{
    in(n); in(h);
    int a[n];
    int min_pos = 0;
    forn(i, n)
    {
        a[i] = nxt();
        if (a[i] < a[min_pos])
            min_pos = i;
    }
    sort(a, a + n);
    if (n == 2)
    {
        cout << "1 1" << endl;
        return 0;
    }
    int mi1 = min(a[0] + a[1] + h, a[1] + a[2]);
    int mi2 = a[0] + a[1];
    int ma1 = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int ma2 = a[n - 1] + a[n - 2];
    if (ma1 - mi1 < ma2 - mi2)
    {
        cout << ma1 - mi1 << endl;
        forn(i, n)
        {
            if (i == min_pos)
                cout << "1 ";
            else
                cout << "2 ";
        }
        return 0;
    }
    cout << ma2 - mi2 << endl;
    forn(i, n)
    {
        cout << "1 ";
    }

    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define out(x) cout << (x);
typedef long double ld;
template <class _T> inline _T sqr(const _T& x) { return x * x; }
template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-8;
char TEMPORARY_CHAR;
typedef long long ll;
typedef unsigned long long u64;
typedef set < int > SI;
typedef vector < int > VI;
typedef vector < vector < int > > VVI;
typedef map < string, int > MSI;
typedef pair < int, int > PII;
const ll INF = 1e17;
const int N = 1 << 17;
inline void input(int &a)
{
    a = 0;
    while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){}
    char neg = 0;
    if (TEMPORARY_CHAR == '-')
    {
        neg = 1;
        TEMPORARY_CHAR = getchar();
    }
    while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0')
    {
        a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
        TEMPORARY_CHAR = getchar();
    }
    if (neg)
        a = -a;
}
inline int nxt() {in(ret); return ret;}

#define x first
#define y second

#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)

#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))

int main()
{
    in(n); in(h);
    int a[n];
    int min_pos = 0;
    forn(i, n)
    {
        a[i] = nxt();
        if (a[i] < a[min_pos])
            min_pos = i;
    }
    sort(a, a + n);
    if (n == 2)
    {
        cout << "1 1" << endl;
        return 0;
    }
    int mi1 = min(a[0] + a[1] + h, a[1] + a[2]);
    int mi2 = a[0] + a[1];
    int ma1 = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int ma2 = a[n - 1] + a[n - 2];
    if (ma1 - mi1 < ma2 - mi2)
    {
        forn(i, n)
        {
            if (i == min_pos)
                cout << "1 ";
            else
                cout << "2 ";
        }
        return 0;
    }
    forn(i, n)
    {
        cout << "1 ";
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<memory.h>
#include<assert.h>
#include<ctype.h>

typedef long long ll;

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
int modint(int a,int b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}
ll modll(ll a,ll b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}
#define mod(a,b) a=modint(a,b)
#define llmod(a,b) a=modll(a,b)
#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define inf (1e9)
#define linf (1e18)
#define pi 3.14159265358979323846

void fileio_in_out()
{
     freopen(".in","r",stdin);
     freopen(".out","w",stdout);
}

void fileio_txt()
{
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
}

//==================================================

int n,m,ans,h,maxf,minf;
int i,j,l;
int a[1111111],b[1111111],c[1111111];

#define swap(a,b) swapnum(&a,&b)
void swapnum(int *a,int *b)
{
     int t;

     t=*a;
     *a=*b;
     *b=t;
}

void sort(int a[],int b[],int l,int r)
{
    int i,j,mid;

    i=l;
    j=r;
    mid=a[(l+r)/2];
    do{
        while(a[i]<mid)
          i++;
        while(a[j]>mid)
          j--;
        if(i<=j)
          {
            swap(a[i],a[j]);
            swap(b[i],b[j]);
            i++;
            j--;
          }
      }while(i<=j);
    if(i<r)
      sort(a,b,i,r);
    if(j>l)
      sort(a,b,l,j);
}

int main()
{
    //fileio_in_out();
    //fileio_txt();

    scanf("%d%d",&n,&h);
    for(i=1;i<=n;i++)
      {
        scanf("%d",&a[i]);
        b[i]=i;
        c[i]=2;
      }

    sort(a,b,1,n);

    minf=a[2]+a[1];
    maxf=a[n]+a[n-1];
    ans=maxf-minf;
    if(n>=3)
      {
        minf=min(a[3]+a[2],a[2]+a[1]+h);
        maxf=max(a[n]+a[n-1],a[n]+a[1]+h);
        if(maxf>=minf&&maxf-minf<ans)
          {
            ans=maxf-minf;
            c[b[1]]=1;
          }
      }

    printf("%d\n",ans);
    for(i=1;i<n;i++)
      printf("%d ",c[i]);
    printf("%d\n",c[n]);

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


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

public class BoringPartition
{
	static Integer n,h;
	static Pair arr[];

	static class Pair implements Comparable<Pair>
	{
		int first,second;

		public Pair(int first,int second)
		{
			this.first = first;
			this.second = second;
		}
		public int compareTo(Pair o) {

			return this.first - o.first;
		}

	}
	public static void main(String[]args)throws Throwable
	{

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = sc.nextInt();
		h = sc.nextInt();
		short ans[] = new short[n];
		Arrays.fill(ans, (short)2);

		arr = new Pair[n];
		for(int i = 0 ; i < n ; ++i)
		{
			arr[i] = new Pair(sc.nextInt(),i);
		}
		Arrays.sort(arr);
		long max = arr[n - 1].first + arr[n - 2].first;
		long min = arr[0].first + arr[1].first;
		long abs = max - min;

		//flip
		long max2 = Math.max(arr[n - 1].first + arr[0].first +h, max);
		long cap =  arr[0].first + arr[1].first + h;
		for(int i = 1 ; i < n - 1 ; ++i)
		{
			if(arr[i].first + arr[i + 1].first < cap)
			{
				cap = arr[i].first + arr[i + 1].first;
				break;
			}
		}
		long abs2 = max2 - cap;
		if(abs2 < abs)
		{
			ans[arr[0].second] = 1;
			abs = abs2;
		}

		out.println(abs);
		for(int i = 0 ; i < n ; ++i)
			out.print(ans[i]+" ");
		out.flush();
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;

		Scanner(InputStream s)  { br = new BufferedReader(new InputStreamReader(s)); }

		String next() throws IOException
		{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();

		}

		int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); }

	}
}


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

public class d
{
	public static void main(String[] args)
	{
		FastScanner in = new FastScanner();
		int n = in.nextInt();
		int h = in.nextInt();
		Pair data[] = new Pair[n];
		for(int i = 0; i < n; i++)
			data[i] = new Pair(in.nextInt(), i);
		Arrays.sort(data);

		int max = data[n-1].v+data[n-2].v;
		int min = data[0].v + data[1].v;
		int min2 = data[0].v + data[1].v + h;
		int max2 = Math.max(max, data[n-1].v + data[0].v + h);
		if(n >= 3)
			min2 = Math.min(min2, data[1].v + data[2].v);

		boolean flag = true;
		if(max2-min2 < max-min)
		{
			System.out.println(max2-min2);
			flag = false;
		}
		else
			System.out.println(max-min);

		for(int i = 0; i < n; i++)
		{
			if(i != 0) System.out.print(" ");
			if(i == data[0].i && !flag)
				System.out.print("1");
			else
				System.out.print("2");
		}
	}

	public static class Pair implements Comparable<Pair>
	{
		int v, i;

		public Pair(int vv, int ii)
		{
			v = vv;
			i = ii;
		}

		@Override
		public int compareTo(Pair o)
		{
			return v - o.v;
		}
	}

	public static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s)
		{
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken()
		{
			while (st == null || !st.hasMoreElements())
			{
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(nextToken());
		}

		long nextLong()
		{
			return Long.parseLong(nextToken());
		}

		double nextDouble()
		{
			return Double.parseDouble(nextToken());
		}

		String next()
		{
			return nextToken();
		}
	}
}


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

public class d
{
	public static void main(String[] args)
	{
		FastScanner in = new FastScanner();
		int n = in.nextInt();
		int h = in.nextInt();
		Pair data[] = new Pair[n];
		for(int i = 0; i < n; i++)
			data[i] = new Pair(in.nextInt(), i);
		Arrays.sort(data);

		int max = data[n-1].v+data[n-2].v;
		int min = data[0].v + data[1].v;
		int min2 = data[0].v + data[1].v + h;
		int max2 = data[n-1].v + data[0].v + h;
		if(n >= 3)
			min2 = Math.min(min2, data[1].v + data[2].v);

		boolean flag = true;
		if(max2-min2 <= max-min)
		{
			System.out.println(max2-min2);
			flag = false;
		}
		else
			System.out.println(max-min);

		for(int i = 0; i < n; i++)
		{
			if(i != 0) System.out.print(" ");
			if(i == data[0].i && !flag)
				System.out.print("1");
			else
				System.out.print("2");
		}
	}

	public static class Pair implements Comparable<Pair>
	{
		int v, i;

		public Pair(int vv, int ii)
		{
			v = vv;
			i = ii;
		}

		@Override
		public int compareTo(Pair o)
		{
			return v - o.v;
		}
	}

	public static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s)
		{
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken()
		{
			while (st == null || !st.hasMoreElements())
			{
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(nextToken());
		}

		long nextLong()
		{
			return Long.parseLong(nextToken());
		}

		double nextDouble()
		{
			return Double.parseDouble(nextToken());
		}

		String next()
		{
			return nextToken();
		}
	}
}


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class CF_148_C {

    static StreamTokenizer in;
    static PrintWriter out;

    static class pair implements Comparable<pair>{
        int a, i;

            public pair(int a, int i){
                this.a = a;
                this.i = i;
            }
        @Override
        public int compareTo(pair o) {
            return this.a - o.a;
        }

    }

    static int nextInt() throws IOException{
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        int n = nextInt(), h = nextInt();
        pair[] a = new pair[n];

        for (int i = 0; i < n; i++){
            a[i] = new pair(nextInt(), i + 1);
        }

        Arrays.sort(a);

        int fmax = a[n - 1].a + a[n - 2].a;
        int fmin = a[0].a + a[1].a;

        int df = fmax - fmin;

        fmax = Math.max(a[0].a + h + a[n - 1].a, fmax);
        fmin = Math.min(a[0].a + h + a[1].a, a[1].a + a[2].a);

        if (n <= 2 || df <= fmax - fmin){
            out.println(df);
            for (int i = 1; i <= n; i++){
                out.print("1 ");
            }
        } else {
            out.println(fmax - fmin);
            for (int i = 1; i <= n; i++){
                if (i != a[0].i)out.print("1 "); else out.print("2 ");
            }
        }

        out.close();
    }

}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long n,i,m[100003],k,p,ans,fix[100003],max1,max2;
vector<long long >A;
main()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>m[i];
if(n==1)
{
cout<<1<<endl;
return 0;
}
for(i=1;i<=n;i++)
{
k=i;p=0;
while(!fix[k])
{
  //           cout<<k<<" ;;;";
p++;
fix[k]=1;
k=m[k];
}
//cout<<"______"<<p<<endl;
A.push_back(p);
}
sort(A.begin(),A.end());
for(i=0;i<A.size()-2;i++)
ans+=A[i]*A[i];
max1=A[A.size()-1];
max2=A[A.size()-2];
ans+=(max1+max2)*(max1+max2);
cout<<ans<<endl;
//system("pause");
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,i,m[100003],k,p,ans,fix[100003],max1,max2;
vector<int>A;
main()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>m[i];
if(n==1)
{
cout<<1<<endl;
return 0;
}
for(i=1;i<=n;i++)
{
k=i;p=0;
while(!fix[k])
{
  //           cout<<k<<" ;;;";
p++;
fix[k]=1;
k=m[k];
}
//cout<<"______"<<p<<endl;
A.push_back(p);
}
sort(A.begin(),A.end());
for(i=0;i<A.size()-2;i++)
ans+=A[i]*A[i];
max1=A[A.size()-1];
max2=A[A.size()-2];
ans+=(max1+max2)*(max1+max2);
cout<<ans<<endl;
//system("pause");
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,i,m[100003],k,p,ans,fix[100003],max1,max2;
vector<int>A;
main()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>m[i];
for(i=1;i<=n;i++)
{
k=i;p=0;
while(!fix[k])
{
  //           cout<<k<<" ;;;";
p++;
fix[k]=1;
k=m[k];
}
//cout<<"______"<<p<<endl;
A.push_back(p);
}
sort(A.begin(),A.end());
for(i=0;i<A.size()-2;i++)
ans+=A[i]*A[i];
max1=A[A.size()-1];
max2=A[A.size()-2];
ans+=(max1+max2)*(max1+max2);
cout<<ans<<endl;
//system("pause");
}


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

const int maxn=1e5+5;

long long n,num;
long long a[maxn];
long long vis[maxn];
priority_queue<long long> pq;

void fnd(long long x)
{
    if(vis[a[x]] == 0)
    {
        vis[a[x]] = 1;
        num++;
        fnd(a[x]);
    }
    else
        return ;
}

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }
    memset(vis,0,sizeof(vis));
    for(int i=1; i<=n; i++)
    {
        num = 1;
        if(vis[i] == 0)
        {
            vis[i] = 1;
            fnd(i);
            pq.push(num);
        }
    }

    long long t=pq.top();
    pq.pop();
    if(!pq.size())
    {
        cout << t*t << endl;
    }
    else
    {
        t+=pq.top();
        pq.pop();
        long long ans=t*t;

        while(pq.size())
        {
            t=pq.top();
            pq.pop();
            ans+=t*t;
        }
        cout << ans << endl;
    }
    return 0;
}


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

const int maxn=1e5+5;

int n,num;
int a[maxn];
int vis[maxn];
priority_queue<int> pq;

void fnd(int x)
{
    if(vis[a[x]] == 0)
    {
        vis[a[x]] = 1;
        num++;
        fnd(a[x]);
    }
    else
        return ;
}

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }
    if(n == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        memset(vis,0,sizeof(vis));
        for(int i=1; i<=n; i++)
        {
            num = 1;
            if(vis[i] == 0)
            {
                vis[i] = 1;
                fnd(i);
                pq.push(num);
            }
        }
        int t=pq.top();
        pq.pop();
        t+=pq.top();
        pq.pop();
        int ans=t*t;

        while(pq.size())
        {
            t=pq.top();
            pq.pop();
            ans+=t*t;
        }
        cout << ans << endl;
    }

    return 0;
}


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

const int maxn=1e5+5;

int n,num;
int a[maxn];
int vis[maxn];
priority_queue<int> pq;

void fnd(int x)
{
    if(vis[a[x]] == 0)
    {
        vis[a[x]] = 1;
        num++;
        fnd(a[x]);
    }
    else
        return ;
}

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }
    memset(vis,0,sizeof(vis));
    for(int i=1; i<=n; i++)
    {
        num = 1;
        if(vis[i] == 0)
        {
            vis[i] = 1;
            fnd(i);
            pq.push(num);
        }
    }

    int t=pq.top();
    pq.pop();
    if(!pq.size())
    {
        cout << t*t << endl;
    }
    else
    {
        t+=pq.top();
        pq.pop();
        int ans=t*t;

        while(pq.size())
        {
            t=pq.top();
            pq.pop();
            ans+=t*t;
        }
        cout << ans << endl;
    }
    return 0;
}


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

const int maxn=1e5+5;

int n,num;
int a[maxn];
int vis[maxn];
priority_queue<int> pq;

void fnd(int x)
{
    if(vis[a[x]] == 0)
    {
        vis[a[x]] = 1;
        num++;
        fnd(a[x]);
    }
    else
        return ;
}

int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        num = 1;
        if(vis[i] == 0)
        {
            vis[i] = 1;
            fnd(i);
            pq.push(num);
        }
    }
    int t=pq.top();
    pq.pop();
    t+=pq.top();
    pq.pop();
    int ans=t*t;

    while(pq.size())
    {
        t=pq.top();
        pq.pop();
        ans+=t*t;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>

bool ok[100001];

int main(){
 int a[100001],n;
 memset(ok,false,sizeof(ok))
 std::vector<int> v;
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v.push_back(tp);
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<v.size();++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>
#include <vector>

bool ok[100001];

int main(){
 int a[100001],n;
 std::vector<int> v;
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v.push_back(tp);
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<v.size();++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>

bool ok[100001];

int main(){
 int a[100001],n;
 std::vector<int> v;
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v.push_back(tp);
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<v.size();++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>
#include <string.h>

bool ok[100001];

int main(){
 int a[100001],n;
 memset(ok,false,sizeof(ok));
 long long v[100001],sz(0);
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v[++sz]=tp;
 }
 long long ans1=0,ans2=0,ans=0;
 for(int i=0;i<=sz;++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>
#include <vector>
#include <string.h>

bool ok[100001];

int main(){
 int a[100001],n;
 std::vector<int> v;
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v.push_back(tp);
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<v.size();++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>
#include <string.h>

bool ok[100001];

int main(){
 int a[100001],n;
 memset(ok,false,sizeof(ok));
 int v[100001],sz(0);
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v[++sz]=tp;
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<=sz;++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <iostream>
#include <vector>
#include <string.h>

bool ok[100001];

int main(){
 int a[100001],n;
 memset(ok,false,sizeof(ok));
 std::vector<int> v;
 std::cin>>n;
 for(int i=1;i<=n;++i)std::cin>>a[i];
 for(int i=1;i<=n;++i){
  if(ok[i])continue;
  int tp=0,s=i;
  while(!ok[a[s]]){
   ok[a[s]]=true;
   ++tp;
   s=a[s];
  }
  v.push_back(tp);
 }
 int ans1=0,ans2=0,ans=0;
 for(int i=0;i<v.size();++i){
  ans+=v[i]*v[i];
  if(v[i]>ans1){
   ans2=ans1;
   ans1=v[i];
  }else if(v[i]>ans2)ans2=v[i];
 }
 std::cout<<ans+2*ans2*ans1;
 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 100005
typedef pair<int,int> pii;
typedef long long ll;

int a[MAX];
vector<int> v;
bool vis[MAX];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",a + i);

    for(int i=1; i<=n; i++)
        if(!vis[i])
    {
        int p = i;
        int c = 0;
        while(!vis[p])
        {
            vis[p] = 1;
            c++;
            p = a[p];
        }
        v.pb(c);
    }

    ll ans = 0;

    sort(all(v));

    ans += v[v.sz - 1];
    if(v.sz >= 2)
        ans += v[v.sz - 2];

    /*for(int i = v.sz - 1; i >= max((int)v.sz - 2,0); i--)
        ans += v[i];*/

    ans *= ans;

    if(v.sz > 2)
    for(int i=0; i<(int)v.sz - 2; i++)
        ans += v[i];

    cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 100005
typedef pair<int,int> pii;
typedef long long ll;

int a[MAX];
vector<int> v;
bool vis[MAX];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",a + i);

    for(int i=1; i<=n; i++)
        if(!vis[i])
    {
        int p = i;
        int c = 0;
        while(!vis[p])
        {
            vis[p] = 1;
            c++;
            p = a[p];
        }
        v.pb(c);
    }

    ll ans = 0;

    sort(all(v));

    ans += v[v.sz - 1];
    if(v.sz >= 2)
        ans += v[v.sz - 2];

    /*for(int i = v.sz - 1; i >= max((int)v.sz - 2,0); i--)
        ans += v[i];*/

    ans *= ans;

    if(v.sz > 2)
    for(int i=0; i<(int)v.sz - 2; i++)
        ans += v[i] * v[i];

    cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 100005
typedef pair<int,int> pii;
typedef long long ll;

int a[MAX];
vector<int> v;
bool vis[MAX];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",a + i);

    for(int i=1; i<=n; i++)
        if(!vis[i])
    {
        int p = i;
        int c = 0;
        while(!vis[p])
        {
            vis[p] = 1;
            c++;
            p = a[p];
        }
        v.pb(c);
    }

    ll ans = 0;

    sort(all(v));

    for(int i = v.sz - 1; i >= max((int)v.sz - 2,0); i--)
        ans += v[i];

    ans *= ans;

    for(int i=0; i<v.sz - 2; i++)
        ans += v[i];

    cout << ans << endl;

}