#include <bits/stdc++.h>
using namespace std;
struct Data {
  int Value, Number;
};
bool operator<(Data A, Data B) { return A.Value < B.Value; }
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return X;
}
int main() {
  int N = Get(), Delta = Get();
  struct Data A[100000];
  for (int i = 0; i < N; i++) {
    A[i].Value = Get();
    A[i].Number = i;
  }
  sort(A, A + N);
  int Best = -1,
      Ans = (A[N - 1].Value + A[N - 2].Value) - (A[0].Value + A[1].Value);
  for (int i = 0; i < N; i++) {
    int L0 = 0;
    while (L0 == i) L0++;
    int L1 = L0 + 1;
    while (L1 == i) L1++;
    int R0 = N - 1;
    while (R0 == i) R0--;
    int R1 = R0 - 1;
    while (R1 == i) R1--;
    int Min = A[L0].Value + A[i].Value + Delta;
    if (L1 < N) Min = min(Min, A[L0].Value + A[L1].Value);
    int Max = A[R0].Value + A[i].Value + Delta;
    if (R1 >= 0) Max = max(Max, A[R0].Value + A[R1].Value);
    if (Max - Min < Ans) {
      Best = A[i].Number;
      Ans = Max - Min;
    }
  }
  printf("%d\n", Ans);
  for (int i = 0; i < N; i++) {
    putchar((i == Best) ? '2' : '1');
    putchar((i + 1 == N) ? '\n' : ' ');
  }
  return 0;
}
