#include <bits/stdc++.h>
using namespace std;
int n;
int a[500000 + 100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  bool ada = false;
  vector<pair<int, int> > id;
  int indeks = -1;
  int inc = 1;
  int len = 0;
  a[0] = 123123;
  a[n + 1] = 123123;
  for (int i = 1; i <= n - 1; i += inc) {
    if (a[i] == 1 && a[i + 1] == 0 && !ada) {
      assert(len == 0);
      ada = true;
      indeks = i;
      inc = 2;
      len++;
      continue;
    }
    if (a[i] == 1 && a[i + 1] == 0 && ada) {
      assert(inc == 2);
      len++;
      continue;
    }
    if ((a[i] != 1 || a[i + 1] != 0) && ada) {
      assert(inc == 2);
      ada = false;
      inc = 1;
      id.emplace_back(indeks, len);
      len = 0;
      indeks = -1;
    }
  }
  if (indeks != -1 && len != 0) {
    id.emplace_back(indeks, len);
  }
  if (id.size() == 0) {
    puts("0");
    for (int i = 1; i <= n; i++) {
      printf("%d ", a[i]);
    }
    return 0;
  }
  int sz = id.size();
  ;
  int ans = 0;
  for (int i = 0; i <= sz - 1; i++) {
    int idx = id[i].first;
    int len = id[i].second;
    int pfft = len;
    if ((idx == 1 || a[idx - 1] == 1) &&
        (a[idx + 2 * len] == 0 || idx + 2 * len - 1 == n)) {
      pfft--;
    }
    ans = max(ans, pfft);
    int kiri = -1;
    int kanan = -1;
    if (a[idx + 2 * len] == 1) {
      kanan = 1;
    } else {
      kanan = 0;
    }
    if (idx == 1 || a[idx - 1] == 1) {
      kiri = 1;
    } else {
      kiri = 0;
    }
    for (int j = idx; j <= idx + len - 1; j++) {
      a[j] = kiri;
    }
    for (int j = idx + len; j <= idx + 2 * len - 1; j++) {
      a[j] = kanan;
    }
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
