#include <bits/stdc++.h>   using namespace std;   const int MAX = 500000 + 24;   int a[MAX];   int main() {     int n, m, ans, tmp, u, v, fc;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     m = a[0];     ans = 0;     for (int i = 0; i < n; i++) {       while (i < n && a[i] == m) {         i++;       }       tmp = 0;       u = i;       if (m == 0) {         while (i + 1 < n && a[i] == 1 && a[i + 1] == 0) {           tmp++;           i += 2;         }       } else {         while (i + 1 < n && a[i] == 0 && a[i + 1] == 1) {           tmp++;           i += 2;         }       }       v = i;       ans = max(ans, tmp);       int j = u;       for (; j < v - tmp; j++) {         a[j] = m;       }       fc = (i < n) ? a[i] : a[n - 1];       for (; j < v; j++) {         a[j] = fc;       }       m = a[i];       i--;     }     printf( %d n , ans);     for (int i = 0; i < n - 1; i++) {       printf( %d  , a[i]);     }     printf( %d n , a[n - 1]);     return 0;   }   