#include <bits/stdc++.h>
using namespace std;
int a[500010], isc[500010];
void fill(int f, int l, int val) {
  for (int i = f; i <= l; i++) a[i] = val;
  return;
}
int calc(int idx) {
  int i, j, k;
  int o, z;
  o = z = 0;
  for (j = idx - 1; j <= idx + 1; j++) {
    if (a[j] == 1)
      o += 1;
    else
      z += 1;
  }
  if (o > z && a[idx] == 0) return 1;
  if (z > o && a[idx] == 1) return 1;
  return 0;
}
int main() {
  int i, j, k, n, f, l, ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) isc[i] = 0;
  for (i = 1; i < n - 1; i++) {
    isc[i] = calc(i);
  }
  f = l = -1;
  for (i = 1; i < n; i++) {
    if (isc[i]) {
      if (f == -1) f = i;
      l = i;
    } else {
      if (f > -1) {
        int one = 0;
        int zero = 0;
        for (j = f; j <= l; j++) {
          if (a[j])
            one += 1;
          else
            zero += 1;
        }
        if (a[f - 1] == a[i] && a[f - 1] == 1)
          fill(f, l, 1);
        else if (a[f - 1] == a[i] && a[f - 1] == 0)
          fill(f, l, 0);
        else if (a[f - 1] == 1 && a[i] == 0) {
          fill(f, f + one - 1, 1);
          fill(f + one, l, 0);
        } else if (a[f - 1] == 0 && a[i] == 1) {
          fill(f, f + one - 1, 0);
          fill(f + one, l, 1);
        }
        ans = max(ans, (l - f + 1));
      }
      f = -1;
      l = -1;
    }
  }
  printf("%d\n", ans / 2 + (ans % 2));
  for (i = 0; i < n; i++) printf("%d ", a[i]);
  printf("\n");
  return 0;
}
