#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 11;
int arr[N];
int lef[N];
int rig[N];
bool vis[N];
int n;
int main() {
  memset(vis, 0, sizeof(vis));
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  arr[0] = arr[1];
  arr[n + 1] = arr[n];
  for (int i = 1; i <= n + 1; ++i) {
    if (arr[i] == arr[i - 1]) vis[i] = vis[i - 1] = true;
  }
  for (int i = 1; i <= n; ++i) {
    if (vis[i] == false)
      lef[i] = lef[i - 1] + 1;
    else
      lef[i] = 0;
  }
  for (int i = n; i >= 1; --i) {
    if (vis[i] == false)
      rig[i] = rig[i + 1] + 1;
    else
      rig[i] = 0;
  }
  int ans = 0;
  for (int i = 0; i <= n + 1; ++i) {
    if (!vis[i]) {
      ans = max(ans, min(lef[i], rig[i]));
      int a = arr[i - lef[i]], b = arr[i + rig[i]];
      if (a == b)
        arr[i] = a;
      else if (lef[i] < rig[i]) {
        arr[i] = a;
      } else if (lef[i] > rig[i]) {
        arr[i] = b;
      } else
        arr[i] = 1;
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) {
    printf("%d", arr[i]);
    if (i != n)
      printf(" ");
    else
      printf("\n");
  }
}
