At school Vasya got an impressive list of summer reading books. Unlike other modern schoolchildren, Vasya loves reading, so he read some book each day of the summer.

As Vasya was reading books, he was making notes in the Reader's Diary. Each day he wrote the orderal number of the book he was reading. The books in the list are numbered starting from 1 and Vasya was reading them in the order they go in the list. Vasya never reads a new book until he finishes reading the previous one. Unfortunately, Vasya wasn't accurate and some days he forgot to note the number of the book and the notes for those days remained empty.

As Vasya knows that the literature teacher will want to check the Reader's Diary, so he needs to restore the lost records. Help him do it and fill all the blanks. Vasya is sure that he spends at least two and at most five days for each book. Vasya finished reading all the books he had started. Assume that the reading list contained many books. So many, in fact, that it is impossible to read all of them in a summer. If there are multiple valid ways to restore the diary records, Vasya prefers the one that shows the maximum number of read books.

Input

The first line contains integer n — the number of summer days (2 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ... an — the records in the diary in the order they were written (0 ≤ ai ≤ 105). If Vasya forgot to write the number of the book on the i-th day, then ai equals 0. 

Output

If it is impossible to correctly fill the blanks in the diary (the diary may contain mistakes initially), print "-1". 

Otherwise, print in the first line the maximum number of books Vasya could have read in the summer if we stick to the diary. In the second line print n integers — the diary with correctly inserted records. If there are multiple optimal solutions, you can print any of them.

Examples

Input

7
0 1 0 0 0 3 0


Output

3
1 1 2 2 3 3 3 


Input

8
0 0 0 0 0 0 0 0


Output

4
1 1 2 2 3 3 4 4 


Input

4
0 0 1 0


Output

1
1 1 1 1 


Input

4
0 0 0 3


Output

-1
#include <bits/stdc++.h>
const int N = 200200;
using namespace std;
int n;
int a[N];
int l[N];
int r[N];
pair<int, int> d[N][7];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!l[a[i]]) {
      l[a[i]] = i;
    }
    r[a[i]] = i;
  }
  vector<int> b;
  vector<pair<int, int> > v;
  for (int i = 1; i < N; i++) {
    if (!l[i]) {
      continue;
    } else if (r[i] - l[i] + 1 > 5) {
      cout << -1 << "\n";
      return 0;
    }
    for (int j = l[i]; j <= r[i]; j++) {
      if (a[j] && a[j] != i) {
        cout << -1 << "\n";
        return 0;
      }
      a[j] = i;
    }
    v.push_back({l[i], r[i]});
    b.push_back(i);
  }
  if (v.empty()) {
    cout << n / 2 << "\n";
    for (int i = 1; i < n; i += 2) {
      cout << i / 2 + 1 << " " << i / 2 + 1 << " ";
    }
    if (n % 2) {
      cout << n / 2;
    }
    return 0;
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < 5; j++) {
      d[i][j] = {-1, -1};
    }
  }
  for (int j = 0; j < 5; j++) {
    int len = v[0].second - v[0].first + j + 1;
    if (v[0].second + j > n) {
      continue;
    }
    for (int h = 0; h < 5; h++) {
      if (len + h < 2 || len + h > 5) {
        continue;
      }
      if ((b[0] - 1) * 2 <= v[0].first - h - 1 &&
          v[0].first - h - 1 <= (b[0] - 1) * 5) {
        d[0][j] = {h, 0};
      }
    }
  }
  for (int i = 1, l; i < v.size(); i++) {
    for (int j = 0; j < 5; j++) {
      int len = v[i].second - v[i].first + j + 1;
      if (v[i].second + j > n) {
        continue;
      }
      for (int h = 0; h < 5; h++) {
        if (len + h < 2 || len + h > 5) {
          continue;
        }
        for (int pre = 0; pre < 5; pre++) {
          if (d[i - 1][pre].first == -1) {
            continue;
          }
          l = v[i].first - v[i - 1].second - 1 - h - pre;
          if (l < 0 || (b[i] - b[i - 1] - 1) * 2 > l ||
              l > (b[i] - b[i - 1] - 1) * 5) {
            continue;
          }
          d[i][j] = {h, pre};
        }
      }
    }
  }
  int shit = -1;
  for (int i = 0; i < 5; i++) {
    if (d[v.size() - 1][i].first == -1) {
      continue;
    } else if (n - v.back().second - i != 1) {
      shit = i;
      break;
    }
  }
  if (shit == -1) {
    cout << -1 << "\n";
    return 0;
  }
  int cnt = n - v.back().second - shit;
  for (int i = v.back().second + shit + 1, g = b.back() + 1; i < n;
       i += 2, g += 1) {
    a[i] = a[i + 1] = g;
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    auto p = d[i][shit];
    for (int j = v[i].first - p.first; j <= v[i].second + shit; j++) {
      a[j] = b[i];
    }
    int l = (i == 0 ? 0 : v[i - 1].second + p.second) + 1;
    vector<int> g;
    for (int j = (i == 0 ? 1 : b[i - 1] + 1); j < b[i]; j++) {
      g.push_back(j);
    }
    if (!g.empty()) {
      int can = (v[i].first - p.first - (i == 0 ? 0 : v[i - 1].second) -
                 p.second - 1);
      int x = can / (int)g.size(), rem = can % (int)g.size();
      for (int j = 0; j < g.size(); j++) {
        int y = x;
        if (rem) {
          y += 1;
          rem -= 1;
        }
        while (y--) {
          a[l] = g[j];
          l += 1;
        }
      }
    }
    shit = p.second;
  }
  if (!a[n]) {
    assert(a[n - 1]);
    a[n] = a[n - 1];
  }
  cout << a[n] << "\n";
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
}
