#include <bits/stdc++.h>
int n[1000000];
int ul[1000000];
int zl[1000000];
int zr[1000000];
int ur[1000000];
int a, b, c, res;
int min(int x, int y) {
  if (x < y) {
    return (x);
  }
  return (y);
}
bool is0(int x) {
  if (n[x] == 1) {
    return (false);
  }
  if (x == 0 || x == a - 1) {
    return (true);
  }
  if (n[x] + n[x - 1] + n[x + 1] < 2) {
    return (true);
  }
  return (false);
}
bool is1(int x) {
  if (n[x] == 0) {
    return (false);
  }
  if (x == 0 || x == a - 1) {
    return (true);
  }
  if (n[x] + n[x - 1] + n[x + 1] > 1) {
    return (true);
  }
  return (false);
}
int main() {
  scanf("%d", &a);
  for (b = 0; b < a; b++) {
    scanf("%d", &n[b]);
  }
  for (b = 0, c = 1000000; b < a; b++) {
    if (is0(b)) {
      c = 0;
    }
    zl[b] = c;
    c++;
  }
  for (b = 0, c = 1000000; b < a; b++) {
    if (is1(b)) {
      c = 0;
    }
    ul[b] = c;
    c++;
  }
  for (b = a - 1, c = 1000000; b >= 0; b--) {
    if (is0(b)) {
      c = 0;
    }
    zr[b] = c;
    c++;
  }
  for (b = a - 1, c = 1000000; b >= 0; b--) {
    if (is1(b)) {
      c = 0;
    }
    ur[b] = c;
    c++;
  }
  for (b = 0; b < a; b++) {
    ul[b] = min(ul[b], ur[b]);
    zl[b] = min(zl[b], zr[b]);
  }
  for (b = 0, res = 0; b < a; b++) {
    if (res < min(ul[b], zl[b])) {
      res = min(ul[b], zl[b]);
    }
    if (ul[b] < zl[b]) {
      n[b] = 1;
    }
    if (zl[b] < ul[b]) {
      n[b] = 0;
    }
    if (ul[b] == zl[b]) {
      n[b] = (n[b] + ul[b]) % 2;
    }
  }
  printf("%d\n", res);
  for (b = 0; b < a; b++) {
    printf("%d", n[b]);
    if (b == a - 1) {
      printf("\n");
    } else {
      printf(" ");
    }
  }
}
