#include <bits/stdc++.h>
using namespace std;
const int N = 500003;
int n, a[N], ans, c;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  ans = -1;
  int i = 0;
  while (i < n) {
    c = 0;
    if (a[i] == 0) {
      int j = i;
      while (j + 1 < n && a[j] == 0 && a[j + 1] == 1) j += 2;
      if (j > i) {
        c = ((j - i) / 2 - 1);
        if (j < n && a[j] == 0) {
          while (i <= j) a[i++] = 0;
          c++;
        } else {
          int k = (j - i) / 2;
          for (int l = 0; l < k; ++l) a[i++] = 0;
          for (int l = 0; l < k; ++l) a[i++] = 1;
        }
      } else
        i++;
    } else {
      int j = i;
      while (j + 1 < n && a[j] == 1 && a[j + 1] == 0) j += 2;
      if (j > i) {
        c = ((j - i) / 2 - 1);
        if (j < n && a[j] == 1) {
          while (i <= j) a[i++] = 1;
          c++;
        } else {
          int k = (j - i) / 2;
          for (int l = 0; l < k; ++l) a[i++] = 1;
          for (int l = 0; l < k; ++l) a[i++] = 0;
        }
      } else
        i++;
    }
    ans = max(ans, c);
  }
  printf("%d\n", ans);
  for (i = 0; i < n; ++i) printf("%d ", a[i]);
  return 0;
}
