#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
int a[MAXN], b[MAXN];
int n, cnt;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  b[1] = a[1];
  b[n] = a[n];
  for (int i = 2; i <= n - 1;) {
    int j = i, cur = a[i];
    while (j + 1 < n && a[j + 1] == (1 ^ cur)) {
      j++;
      cur ^= 1;
    }
    int pre = a[i - 1], next = a[j + 1], ri = j;
    while (a[i] == pre && i <= j) {
      b[i] = a[i];
      i++;
    }
    if (i <= j) {
      while (a[j] == next && j >= i) {
        b[j] = a[j];
        j--;
      }
      if (i <= j) {
        if (a[i] == 0 && a[j] == 0) {
          for (int k = i; k <= j; k++) b[k] = 1;
          cnt = max(cnt, (j - i + 2) / 2);
        } else if (a[i] == 1 && a[j] == 1) {
          for (int k = i; k <= j; k++) b[k] = 0;
          cnt = max(cnt, (j - i + 2) / 2);
        } else if (a[i] == 0 && a[j] == 1) {
          int x = i + (j - i + 1) / 2 - 1;
          for (int k = i; k <= x; k++) b[k] = 1;
          for (int k = x + 1; k <= j; k++) b[k] = 0;
          cnt = max(cnt, (j - i + 1) / 2);
        } else {
          int x = i + (j - i + 1) / 2 - 1;
          for (int k = i; k <= x; k++) b[k] = 0;
          for (int k = x + 1; k <= j; k++) b[k] = 1;
          cnt = max(cnt, (j - i + 1) / 2);
        }
      }
    }
    i = ri + 1;
  }
  cout << cnt << '\n';
  for (int i = 1; i <= n; i++) cout << b[i] << ' ';
  cout << '\n';
  return 0;
}
