#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500001;
const int INF = 0x7f7f7f7f;
int cases;
template <class T>
inline void read(T& x) {
  int c;
  for (c = getchar(); ~c && c < 33; c = getchar())
    ;
  for (x = 0; c > 32; x = x * 10 + c - '0', c = getchar())
    ;
}
bool s[MAXN];
vector<pair<int, int> > v;
int main() {
  int n, x;
  read(n);
  for (int i = 0; i < n; i++) {
    read(x);
    if (x) s[i] = 1;
  }
  int st = -1;
  for (int i = 0, j = 1; j < n; i++, j++) {
    if (s[i] ^ s[j]) {
      if (st == -1) st = i;
    } else {
      if (~st) v.emplace_back(st, i);
      st = -1;
    }
  }
  if (~st) {
    v.emplace_back(st, n - 1);
  }
  int ans = 0;
  for (const auto& y : v) {
    ans = max(ans, (y.second - y.first) / 2);
    if ((y.second - y.first) & 1) {
      if (s[y.first]) {
        for (int i = y.first; i <= y.first + (y.second - y.first) / 2; i++) {
          s[i] = 1;
        }
        for (int i = y.first + (y.second - y.first) / 2 + 1; i <= y.second;
             i++) {
          s[i] = 0;
        }
      } else {
        for (int i = y.first; i <= y.first + (y.second - y.first) / 2; i++) {
          s[i] = 0;
        }
        for (int i = y.first + (y.second - y.first) / 2 + 1; i <= y.second;
             i++) {
          s[i] = 1;
        }
      }
    } else {
      if (s[y.first]) {
        for (int i = y.first; i <= y.second; i++) {
          s[i] = 1;
        }
      } else {
        for (int i = y.first; i <= y.second; i++) {
          s[i] = 0;
        }
      }
    }
  }
  printf("%d\n", ans);
  printf("%d", s[0]);
  for (int i = 1; i < n; i++) {
    printf(" %d", s[i]);
  }
  putchar('\n');
}
