#include <bits/stdc++.h>
int main() {
  std::vector<bool> mas;
  std::vector<int> intmas;
  std::string str;
  int n;
  scanf("%d", &n);
  mas.resize(n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    mas[i] = a;
  }
  int count = 0;
  if (mas[0]) {
    intmas.push_back(-1);
  } else {
    intmas.push_back(0);
  }
  for (int i = 1; i < n - 1; i++) {
    if (mas[i]) {
      if (mas[i - 1] || mas[i + 1]) {
        if (count != 0) {
          intmas.push_back(count);
          count = 0;
        }
        intmas.push_back(-1);
        continue;
      }
    } else {
      if (!mas[i - 1] || !mas[i + 1]) {
        if (count != 0) {
          intmas.push_back(count);
          count = 0;
        }
        intmas.push_back(0);
        continue;
      }
    }
    count++;
  }
  if (count != 0) {
    intmas.push_back(count);
  }
  if (mas[n - 1]) {
    intmas.push_back(-1);
  } else {
    intmas.push_back(0);
  }
  int maxcount = 0;
  for (int i = 0; i < intmas.size() - 1; i++) {
    if (intmas[i] > 0) {
      if (intmas[i] > maxcount) maxcount = intmas[i];
      int a = intmas[i];
      for (; a > intmas[i] / 2; a--) {
        str.push_back(intmas[i - 1] * -1 + '0');
        str.push_back(' ');
      }
      for (; a > 0; a--) {
        str.push_back(intmas[i + 1] * -1 + '0');
        str.push_back(' ');
      }
    } else {
      str.push_back(intmas[i] * -1 + '0');
      str.push_back(' ');
    }
  }
  str.push_back(intmas[intmas.size() - 1] * -1 + '0');
  printf("%d\n%s", maxcount % 2 ? (maxcount + 1) / 2 : maxcount / 2,
         str.c_str());
  return 0;
}
