#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long result = 0;
  long long beforeIslandPos = 0;
  long long beforeIslandType = a[0];
  long long subsequenceSeaCount = 0;
  long long beforeType = a[0];
  vector<int> b(n);
  b[0] = a[0];
  b[n - 1] = a[n - 1];
  for (long long i = 1; i < n; ++i) {
    if (i == beforeIslandPos + 1 && a[i] == beforeIslandType) {
      beforeIslandPos++;
      b[i] = a[i];
    } else if (a[i] == beforeType) {
      subsequenceSeaCount--;
      result = max(result, (subsequenceSeaCount + 1) / 2);
      if (subsequenceSeaCount % 2 == 1) {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
      } else {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
        for (long long j = beforeIslandPos;
             j < beforeIslandPos + subsequenceSeaCount / 2 + 1; ++j)
          b[j] = beforeIslandType;
      }
      beforeIslandPos = i;
      beforeIslandType = a[i];
      b[i] = a[i];
      subsequenceSeaCount = 0;
    } else if (i == n - 1) {
      result = max(result, (subsequenceSeaCount + 1) / 2);
      if (subsequenceSeaCount % 2 == 1) {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
      } else {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
        for (long long j = beforeIslandPos;
             j < beforeIslandPos + subsequenceSeaCount / 2 + 1; ++j)
          b[j] = beforeIslandType;
      }
      beforeIslandPos = i;
      beforeIslandType = a[i];
      b[i] = a[i];
      subsequenceSeaCount = 0;
    } else {
      subsequenceSeaCount++;
    }
    beforeType = a[i];
  }
  cout << result << endl;
  cout << b[0];
  for (long long i = 1; i < n; ++i) cout << " " << b[i];
  cout << endl;
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decided to try it in practice.

Applying the simplest variant of median smoothing to the sequence of numbers a1, a2, ..., an will result a new sequence b1, b2, ..., bn obtained by the following algorithm:

  * b1 = a1, bn = an, that is, the first and the last number of the new sequence match the corresponding numbers of the original sequence. 
  * For i = 2, ..., n - 1 value bi is equal to the median of three values ai - 1, ai and ai + 1. 



The median of a set of three numbers is the number that goes on the second place, when these three numbers are written in the non-decreasing order. For example, the median of the set 5, 1, 2 is number 2, and the median of set 1, 0, 1 is equal to 1.

In order to make the task easier, Vasya decided to apply the method to sequences consisting of zeros and ones only.

Having made the procedure once, Vasya looked at the resulting sequence and thought: what if I apply the algorithm to it once again, and then apply it to the next result, and so on? Vasya tried a couple of examples and found out that after some number of median smoothing algorithm applications the sequence can stop changing. We say that the sequence is stable, if it does not change when the median smoothing is applied to it.

Now Vasya wonders, whether the sequence always eventually becomes stable. He asks you to write a program that, given a sequence of zeros and ones, will determine whether it ever becomes stable. Moreover, if it ever becomes stable, then you should determine what will it look like and how many times one needs to apply the median smoothing algorithm to initial sequence in order to obtain a stable one.

Input

The first input line of the input contains a single integer n (3 ≤ n ≤ 500 000) — the length of the initial sequence.

The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 1), giving the initial sequence itself.

Output

If the sequence will never become stable, print a single number  - 1.

Otherwise, first print a single integer — the minimum number of times one needs to apply the median smoothing algorithm to the initial sequence before it becomes is stable. In the second line print n numbers separated by a space — the resulting sequence itself.

Examples

Input

4
0 0 1 1


Output

0
0 0 1 1


Input

5
0 1 0 1 0


Output

2
0 0 0 0 0

Note

In the second sample the stabilization occurs in two steps: <image>, and the sequence 00000 is obviously stable.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long result = 0;
  long long beforeIslandPos = 0;
  long long beforeIslandType = a[0];
  long long subsequenceSeaCount = 0;
  long long beforeType = a[0];
  vector<int> b(n);
  b[0] = a[0];
  b[n - 1] = a[n - 1];
  for (long long i = 1; i < n; ++i) {
    if (i == beforeIslandPos + 1 && a[i] == beforeIslandType) {
      beforeIslandPos++;
      b[i] = a[i];
    } else if (a[i] == beforeType) {
      subsequenceSeaCount--;
      result = max(result, (subsequenceSeaCount + 1) / 2);
      if (subsequenceSeaCount % 2 == 1) {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
      } else {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
        for (long long j = beforeIslandPos;
             j < beforeIslandPos + subsequenceSeaCount / 2 + 1; ++j)
          b[j] = beforeIslandType;
      }
      beforeIslandPos = i;
      beforeIslandType = a[i];
      b[i] = a[i];
      subsequenceSeaCount = 0;
    } else if (i == n - 1) {
      result = max(result, (subsequenceSeaCount + 1) / 2);
      if (subsequenceSeaCount % 2 == 1) {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
      } else {
        for (long long j = beforeIslandPos; j < i; ++j) b[j] = a[i];
        for (long long j = beforeIslandPos;
             j < beforeIslandPos + subsequenceSeaCount / 2 + 1; ++j)
          b[j] = beforeIslandType;
      }
      beforeIslandPos = i;
      beforeIslandType = a[i];
      b[i] = a[i];
      subsequenceSeaCount = 0;
    } else {
      subsequenceSeaCount++;
    }
    beforeType = a[i];
  }
  cout << result << endl;
  cout << b[0];
  for (long long i = 1; i < n; ++i) cout << " " << b[i];
  cout << endl;
  return 0;
}

```