#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vi v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vi mask(n);
  vi ndx(n);
  for (int i = 0, prev = 0; i < n; i++)
    if (!i || i == n - 1 || v[i] == v[i - 1] || v[i] == v[i + 1]) {
      mask[i] = 1;
      ndx[i] = prev;
      prev = i;
    }
  int ans = 0;
  for (int i = 1; i < n; i++)
    if (mask[i]) {
      ans = max(ans, (i - ndx[i]) / 2);
      auto l = begin(v) + ndx[i] + 1;
      auto r = begin(v) + i;
      if (v[i] != v[ndx[i]]) {
        sort(l, r);
        if (!v[i]) reverse(l, r);
      } else
        fill(l, r, v[i]);
    }
  cout << ans << endl;
  for (auto x : v) cout << x << ' ';
  cout << endl;
  return 0;
}
