#include <bits/stdc++.h>
using namespace std;
int N;
int f[500005];
vector<int> ans;
int start[500005];
int main() {
  scanf("%d", &N);
  int one = 0, zero = 0;
  int ret = 0;
  int pre, cur;
  for (int i = 1; i <= N; i++) scanf("%d", &f[i]);
  pre = f[1];
  int P = 0;
  f[N + 1] = -1;
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    while (f[i] == f[i + 1]) {
      cnt++;
      i++;
    }
    start[i] = cnt;
    if (!P) P = i;
  }
  for (int i = 1; i <= P; i++) ans.push_back(f[1]);
  if (start[N] == 0) start[N] = 1;
  for (int i = P + 1; i <= N;) {
    if (f[i]) one++;
    if (!f[i]) zero++;
    if (start[i] == 0) {
      i++;
      continue;
    } else {
      if (pre == f[i]) {
        for (int j = 1; j <= zero + one; j++) ans.push_back(pre);
      }
      if (pre == 1 && f[i] == 0) {
        for (int j = 1; j <= one; j++) ans.push_back(1);
        for (int j = 1; j <= zero; j++) ans.push_back(0);
      }
      if (pre == 0 && f[i] == 1) {
        for (int j = 1; j <= zero; j++) ans.push_back(0);
        for (int j = 1; j <= one; j++) ans.push_back(1);
      }
      pre = f[i];
      if (f[i])
        one -= (start[i] + 1);
      else
        zero -= (start[i] + 1);
      ret = max(ret, one);
      ret = max(ret, zero);
      i++;
      one = 0;
      zero = 0;
    }
  }
  printf("%d\n", ret);
  for (int i = 0; i < N; i++) printf("%d ", ans[i]);
  return 0;
}
