#include <bits/stdc++.h>
using namespace std;
int a[500050], b[500050];
int main() {
  int n, m, i, j, num, chang, qian, kaishi;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    a[n + 1] = -1;
    num = 0;
    qian = a[1];
    chang = 1;
    kaishi = 1;
    for (i = 2; i <= n; i++) {
      if (a[i] == 1) {
        if (qian == 0) {
          chang++;
          qian = 1;
        } else {
          if (chang % 2 == 1) {
            for (j = kaishi; j <= i - 1; j++) {
              a[j] = qian;
            }
          } else {
            for (j = kaishi; j < kaishi + chang / 2; j++) {
              a[j] = (1 ^ qian);
            }
            for (j = kaishi + chang / 2; j <= i - 1; j++) {
              a[j] = qian;
            }
          }
          kaishi = i;
          qian = a[i];
          num = max((chang - 1) / 2, num);
          chang = 1;
        }
      } else if (a[i] == 0) {
        if (qian == 1) {
          chang++;
          qian = 0;
        } else {
          if (chang % 2 == 1) {
            for (j = kaishi; j <= i - 1; j++) {
              a[j] = qian;
            }
          } else {
            for (j = kaishi; j < kaishi + chang / 2; j++) {
              a[j] = (1 ^ qian);
            }
            for (j = kaishi + chang / 2; j <= i - 1; j++) {
              a[j] = qian;
            }
          }
          kaishi = i;
          qian = a[i];
          num = max((chang - 1) / 2, num);
          chang = 1;
        }
      }
    }
    num = max((chang - 1) / 2, num);
    if (chang % 2 == 1) {
      for (j = kaishi; j <= n; j++) {
        a[j] = qian;
      }
    } else {
      for (j = kaishi; j < kaishi + chang / 2; j++) {
        a[j] = (1 ^ qian);
      }
      for (j = kaishi + chang / 2; j <= n; j++) {
        a[j] = qian;
      }
    }
    printf("%d\n", num);
    for (i = 1; i <= n; i++) {
      if (i == n)
        printf("%d\n", a[i]);
      else
        printf("%d ", a[i]);
    }
  }
  return 0;
}
