#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const double eps = 0.0001;
void solution() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int zeros = 0, ones = 0;
  if (a[0] == 0) {
    zeros++;
  } else if (a[0] == 1) {
    ones++;
  }
  vector<char> Main(n, '-');
  for (int i = 1; i < n; i++) {
    if (a[i] == 1) {
      if (zeros > 1) {
        Main[i - 1] = 'r';
        Main[i - zeros] = 'l';
        for (int j = i - zeros + 1; j <= i - 2; j++) {
          Main[j] = '+';
        }
      }
      zeros = 0;
      ones++;
    } else if (a[i] == 0) {
      if (ones > 1) {
        Main[i - 1] = 'r';
        Main[i - ones] = 'l';
        for (int j = i - ones + 1; j <= i - 2; j++) {
          Main[j] = '+';
        }
      }
      ones = 0;
      zeros++;
    }
  }
  int i = n;
  if (zeros > 1) {
    Main[i - 1] = 'r';
    Main[i - zeros] = 'l';
    for (int j = i - zeros + 1; j <= i - 2; j++) {
      Main[j] = '+';
    }
  } else if (ones > 1) {
    Main[i - 1] = 'r';
    Main[i - ones] = 'l';
    for (int j = i - ones + 1; j <= i - 2; j++) {
      Main[j] = '+';
    }
  }
  i = 1;
  int k;
  int step = 0;
  while (i < n - 1) {
    if (Main[i] == '-') {
      k = n - 1;
      for (int j = i + 1; j < n; j++) {
        if (Main[j] == 'l') {
          k = j;
          break;
        }
      }
      step = max(step, (k - i + 1) / 2);
      int len = k - (i - 1) + 1;
      if (len % 2 == 0) {
        int center = (i - 1 + k) / 2;
        int left, right;
        if (a[i - 1] == 0) {
          left = 0;
          right = 1;
        } else if (a[i - 1] == 1) {
          left = 1;
          right = 0;
        }
        for (int j = i - 1; j <= k; j++) {
          if (j <= center) {
            a[j] = left;
          } else {
            a[j] = right;
          }
        }
      } else if (len % 2 == 1) {
        if (a[i - 1] == 0) {
          for (int j = i; j <= k - 1; j++) {
            a[j] = 0;
          }
        } else if (a[i - 1] == 1) {
          for (int j = i; j <= k - 1; j++) {
            a[j] = 1;
          }
        }
      }
      i = k + 1;
    } else {
      i++;
    }
  }
  cout << step << "\n";
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
}
void include_file() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  solution();
  return 0;
}
