#include <bits/stdc++.h>
using namespace std;
int a[500000];
int p[500000];
int ans1[500000];
int ans2[500000];
int ans[500000];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 2; i <= n - 1; i++) {
    if (a[i] == a[i - 1] or a[i] == a[i + 1]) {
      p[i] = 0;
    } else {
      p[i] = 10000000;
    }
  }
  int cut1 = 0;
  for (int i = 2; i <= n - 1; i++) {
    ans1[i] = min(cut1 + 1, p[i]);
    cut1 = ans1[i];
  }
  int cut2 = 0;
  for (int i = 1; i <= n - 2; i++) {
    ans2[n - i] = min(cut2 + 1, p[n - i]);
    cut2 = ans2[n - i];
  }
  for (int i = 1; i <= n; i++) {
    if (i == 1 or i == n) {
      ans[i] = 0;
    } else {
      ans[i] = min(ans1[i], ans2[i]);
    }
  }
  int bap = 0;
  for (int i = 1; i <= n; i++) {
    bap = max(bap, ans[i]);
  }
  cout << bap << endl;
  for (int i = 1; i <= n; i++) {
    if (ans[i] % 2 == 1) {
      cout << 1 - a[i] << " ";
    } else {
      cout << a[i] << " ";
    }
  }
  return 0;
}
