#include <bits/stdc++.h>   using namespace std;   vector<int> r;   vector<int> l;   int n, ans, a[550000];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     a[0] = a[1];     a[n + 1] = a[n];     for (int i = 1; i <= n; i++) {       if (a[i] == a[i + 1] && a[i] != a[i - 1]) r.push_back(i);       if (a[i] != a[i + 1] && a[i] == a[i - 1]) l.push_back(i);     }     for (int i = 0; i < l.size(); i++) ans = max(ans, r[i] - l[i]);     cout << ans / 2 << endl;     for (int i = 0; i < l.size(); i++)       if (a[l[i]] == a[r[i]])         for (int j = l[i]; j <= r[i]; j++) a[j] = a[l[i]];       else {         for (int j = l[i]; j <= (r[i] + l[i]) / 2; j++) a[j] = a[l[i]];         for (int j = (r[i] + l[i]) / 2 + 1; j <= r[i]; j++) a[j] = a[r[i]];       }     for (int i = 1; i <= n; i++) cout << a[i] <<    ;   }   