#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long MAX = 2e6 + 7;
const long long dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const long long dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
long long i, j, k, t, n, q, l, r, mid;
long long a[MAX];
long long cnt1, cnt0, mini, maxi;
void solve() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  cnt1 = cnt0 = l = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 0)
      cnt0++;
    else
      cnt1++;
    if (i + 1 < n && a[i + 1] == a[i]) {
      if (cnt1 == cnt0) {
        mid = (l + i) / 2;
        for (j = l; j < mid + 1; j++) a[j] = a[l];
        for (j = mid + 1; j < i; j++) a[j] = 1 - a[l];
        mini = min(cnt1, cnt0) - 1;
        if (mini > maxi) maxi = mini;
      } else {
        if (cnt1 > cnt0)
          for (j = l; j < i; j++) a[j] = 1;
        else
          for (j = l; j < i; j++) a[j] = 0;
        mini = min(cnt1, cnt0);
        if (mini > maxi) maxi = mini;
      }
      cnt0 = cnt1 = 0;
      l = i + 1;
    }
  }
  if (cnt1 == cnt0) {
    mid = (l + i) / 2;
    for (j = l; j < mid; j++) a[j] = a[l];
    for (j = mid; j < i; j++) a[j] = 1 - a[l];
    mini = min(cnt1, cnt0) - 1;
    if (mini > maxi) maxi = mini;
  } else {
    if (cnt1 > cnt0)
      for (j = l; j < i; j++) a[j] = 1;
    else
      for (j = l; j < i; j++) a[j] = 0;
    mini = min(cnt1, cnt0);
    if (mini > maxi) maxi = mini;
  }
  cout << maxi << endl;
  for (i = 0; i < n; i++) cout << a[i] << " ";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
