#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n), ans(n);
  int k0 = 0, k1 = 0;
  int b = 0;
  int m = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0) k0++;
    if (a[i] == 1) k1++;
    if (i == n - 1 || a[i] == a[i + 1]) {
      if (k0 > k1) {
        for (int j = b; j < i + 1; ++j) {
          ans[j] = 0;
        }
        m = max(m, k1);
      } else if (k1 > k0) {
        for (int j = b; j < i + 1; ++j) {
          ans[j] = 1;
        }
        m = max(m, k0);
      } else {
        if (a[b] == 1) {
          for (int j = b; j < b + k1; ++j) {
            ans[j] = 1;
          }
          for (int j = b + k1; j < i + 1; ++j) {
            ans[j] = 0;
          }
        } else {
          for (int j = b; j < b + k1; ++j) {
            ans[j] = 0;
          }
          for (int j = b + k1; j < i + 1; ++j) {
            ans[j] = 1;
          }
        }
        m = max(m, k1 - 1);
      }
      b = i + 1;
      k1 = 0;
      k0 = 0;
    }
  }
  cout << m << '\n';
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  return 0;
}
