#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x < y ? x : y; }
int main() {
  int n, h, f1, f2, ans;
  while (~scanf("%d%d", &n, &h)) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(b, b + n);
    f1 = b[n - 1] + b[n - 2] - b[0] - b[1];
    f2 = b[n - 1] - min(b[0] + h, b[2]) - b[1] + max(b[n - 2], b[0] + h);
    if (f2 < f1) {
      cout << f2 << endl;
      ans = b[0];
    } else {
      cout << f1 << endl;
      ans = -1;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == ans) {
        cout << 1 << " ";
        ans = -1;
      } else
        cout << 2 << " ";
    }
    cout << endl;
  }
  return 0;
}
