#include <bits/stdc++.h>
using namespace std;
inline long long int Max(long long int a, long long int b) {
  return (a > b ? a : b);
}
inline long long int Min(long long int a, long long int b) {
  return (a < b ? a : b);
}
int n;
long long int m;
long long int num[100005];
long long int entrada[100005];
int main() {
  scanf("%d %I64d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf(" %I64d", &num[i]);
    entrada[i] = num[i];
  }
  sort(num + 1, num + 1 + n);
  if (n == 2) {
    printf("0\n1 1\n");
  } else {
    if ((num[n] + num[n - 1]) - (num[1] + num[2]) <=
        (num[n] + Max(num[1] + m, num[n - 1])) -
            Min(num[1] + m + num[2], num[2] + num[3])) {
      printf("%I64d\n", (num[n] + num[n - 1]) - (num[1] + num[2]));
      for (int i = 1; i <= n; i++) printf("1 ");
    } else {
      bool lol = true;
      printf("%I64d\n", (num[n] + Max(num[1] + m, num[n - 1])) -
                            Min(num[1] + m + num[2], num[2] + num[3]));
      for (int i = 1; i <= n; i++)
        if (num[1] == entrada[i] && lol) {
          lol = false;
          printf("2 ");
        } else
          printf("1 ");
    }
  }
  return 0;
}
