#include <bits/stdc++.h>
using namespace std;
bool a[500005];
struct Evento {
  int x, y, a, b, c;
};
int main() {
  int n, v;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v);
    a[i] = v;
  }
  a[0] = a[1];
  a[n + 1] = a[n];
  int i = 1, j, c;
  vector<Evento> h;
  int ans = 0;
  while (i <= n) {
    j = i + 1;
    if (!a[i]) {
      c = 0;
      while (j <= n && a[j - 1] ^ a[j]) {
        if (a[j]) c++;
        j++;
      }
      if (a[j - 1]) j--, c--;
      c += min(a[i - 1], a[j]);
      Evento e = {i, j - 1, a[i - 1], a[j], c};
      if (!a[i - 1]) e.x++;
      if (!a[j]) e.y--;
      h.push_back(e);
      ans = max(ans, c);
    }
    i = j;
  }
  printf("%d\n", ans);
  for (Evento e : h) {
    for (int i = 0; i < e.c; i++) a[e.x + i] = e.a;
    for (int i = 0; i < e.c; i++) a[e.y - i] = e.b;
  }
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  return 0;
}
