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
import java.util.*;
import java.io.*;

public class Reading {
    public static void main(String[] args) throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        n = Integer.parseInt(rd.readLine());
        a = new int[n];
        StringTokenizer st = new StringTokenizer(rd.readLine());
        for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        boolean allzero = true;
        for(int i=0; i<n; i++) if(a[i]!=0) allzero = false;
        if(allzero){
            int cur = 1;
            pw.println(n/2);
            for(int i=0; i<n; i++){
                pw.print(cur+" ");
                if(i%2==1 && i!=n-2){
                    cur++;
                }
            }
            pw.println();
            pw.flush();
            return;
        }
        if(a[0]!=0 && a[0]!=1){
            System.out.println(-1);
            return;
        }
        a[0] = 1;
        if(!isValidBasic()){
            System.out.println(-1);
            return;
        }
        prev = new int[n+1];
        Arrays.fill(prev, 0);
        int pr = 0;
        for(int i=0; i<n; i++){
            int cur = a[i];
            prev[i] = pr;
            if(cur==0) continue;
            if(cur==pr) continue;
            pr = cur;
        }
        int nxt = 0;
        for(int i=n-1; i>=0; i--){
            int cur = a[i];
            next[i] = nxt;
            if(cur==0 || cur==nxt) continue;
            nxt = cur;
        }
    //  System.out.println(Arrays.toString(next));
    //  System.out.println(Arrays.toString(prev));
        for(int i=0; i<n; i++){
            if(R[i]==-1) continue;
            int max = 0;
            for(int t=0; t<6; t++){
                if(R[i]+1+t>=n) break;
                if(a[R[i]+t+1]==0){
                    max = t+1;
                }
                else break;
            }
            empty[i] = max;
        }
        dp = new boolean[n+1][6]; // dp[x][len] means whether we can end x-th book in R[x]+len-th position. (R[x]!=-1)
        been = new boolean[n+1][6];
        int max = 0;
        for(int i=0; i<n; i++) max = Math.max(max, a[i]);
        for(int d=0; d<5; d++){
            if(get(max, d)){
    //          System.out.println(max+" "+d+" recovering!");
                recoverReal(max, d, pw);
                break;
            }
        }
        if(ans.size()!=n){
            if(n<20000)
                System.out.println("-1");
            else
                System.out.println("-1");
            return;
        }
        Collections.sort(ans);
        pw.println(ans.get(ans.size()-1));
        for(int i=0; i<ans.size(); i++){
            pw.print(ans.get(i)+" ");
        }
        pw.println();
        pw.flush();
    //  System.out.println(possible(2, 5, 1));
    //  System.out.println(get(1, 0));
    }
    
    static void recoverStep(int x, int start, PrintWriter pw){
    //  System.out.println("recover "+x+" from "+start);
        if(start==n) return;
        for(int d=0; d<5; d++){
            if(get(x, d)){
                for(int j=start; j<=R[x]+d; j++){
                    pw.print(x+" ");
                }
                if(R[x]+d==n-1) return;
                int newStartPos = R[x]+d+1;
                int nxt = next[newStartPos];
    //          System.out.println("newStartPos "+newStartPos+" "+nxt);
                if(nxt==0){
                    int curNum = x + 1;
                    for(int j=newStartPos; j<n; j++){
                        pw.print(curNum+" ");
                        if((j-newStartPos)%2==1){
                            if(j!=n-2)
                                curNum++;
                        }
                    }
                    return;
                }
                for(int e=0; e<5; e++){
                    if(get(nxt, e)){
                        int y = START[nxt][e];
                        fillMiddle(newStartPos, y-1, x+1, nxt-1, pw);
                        recoverStep(nxt, y, pw);
            //          System.out.println("fin " +ans);
                        return;
                    }
                }
            }
        }
    }
    
    static ArrayList<Integer> ans = new ArrayList<Integer>();
    
    static void recoverReal(int x, int d, PrintWriter pw){
    int start = START[x][d];
        if(R[x]+d==n-1 || (a[R[x]+d+1]==0 && next[R[x]+d+1]==0)){
            int cur = x + 1;
            for(int i=R[x]+d+1; i<n; i++){
                ans.add(cur);
                if((i-R[x]-d-1)%2==1 && i!=n-2){
                    cur++;
                }
            }
        }
        for(int i=start; i<=R[x]+d; i++) ans.add(x);
        if(x==1){
        //  for(int i=0; i<=R[x]+d; i++) ans.add(1);
            return;
        }
        int pr = (a[start-1]!=0 ? a[start-1] : prev[start-1]);
        for(int e=0; e<5; e++){
            if(get(pr, e) && possible(R[pr]+e+1, start-1, x-pr-1)){
                fillMiddle(R[pr]+e+1, start-1, pr+1, x-1, pw);
                recoverReal(pr, e, pw);
            //  System.out.println("fin "+ans);
                return;
            }
        }
    }
    
    static void fillMiddle(int start, int end, int x, int y, PrintWriter pw){
            if(start>end) return;
        int qnt = y-x+1;
        if(qnt<=0) return;
        if((end-start+1)<2*qnt || (end-start+1)>5*qnt){
            System.out.println("something went wrong");
            System.exit(0);
        }
        int curIndex = start;
        for(int i=x; i<=y; i++){
            for(int d=2; d<=5; d++){
                // consider to put i on positions [curIndex, curIndex+d-1]
                int newIndex = curIndex + d;
                if((end-newIndex+1)>=2*(qnt-1) && (end-newIndex+1)<=5*(qnt-1)){
                    for(int j=curIndex; j<curIndex+d; j++){
                        ans.add(i);
                    }
                    curIndex += d;
                    qnt--;
                    break;
                }
            }
        }
    }
    
    static int[] next = new int[200000];
    
    static boolean get(int x, int len){
        if(been[x][len])
            return dp[x][len];
        if(R[x]+len-1>=n || len>empty[x])
            return false;
        if(R[x]+len-L[x]>4)
            return false;
        if(x==1){
            if(R[1]+len<=0) return false;  
            if(R[1]+len!=n-2)
                return true;
            return false;
        }
        if(R[x]+len==n-2)
            return false;
        if(x==3 && len==1){
        //  System.out.println("movedi");
        }
        for(int start=L[x]; start>=0; start--){
            if(a[start]!=0 && a[start]!=x) break;
            if(R[x]+len-start<1) continue;
            if(R[x]+len-start>4) break;
            if(a[start]!=0 && a[start]!=x) break;
            // (x-1) should end at start-1
            int pr = (a[start-1]!=0 ? a[start-1] : prev[start-1]);
            for(int d=0; d<=4; d++){
                // consider number pr to end at R[pr]+D.
                if(R[pr]+d-L[pr]>4) break;
                if(R[pr]+d>=start) break;
                if(possible(R[pr]+d+1, start-1, x-pr-1) && get(pr, d)){
                    been[x][len] = true;
                    START[x][len] = start;
                    return dp[x][len] = true;
                }
            }
        }
        been[x][len] = true;
        return dp[x][len] = false;
    }
    
    static int[][] START = new int[100001][5];
            
            
    static int[] empty = new int[200000];
    
    static boolean possible(int from, int to, int num){
        if(from>to) return num<=0;
        int len = to-from+1;
        return 2*num <= len && len <= 5*num;
    }
    
    static int[] prev;
    
    static boolean[][] dp;

    static boolean[][] been;
    
    static boolean isValidBasic(){
        L = new int[200001];
        R = new int[200001];
        Arrays.fill(L, -1);
        Arrays.fill(R, -1);
        for(int i=0; i<n; i++){
            int cur = a[i];
            if(cur==0) continue;
            if(L[cur]==-1){
                L[cur] = i;
                R[cur] = i;
            }
            else{
                R[cur] = i;
                if(R[cur]-L[cur]>4)
                    return false;
            }
        }
        for(int i=1; i<=200000; i++){
            if(L[i]==-1) continue;
            for(int j=L[i]; j<=R[i]; j++){
                if(a[j]!=0 && a[j]!=i)
                    return false;
            }
        }
        return true;
    }
    
    
    
    
    static int[] L, R;
    static int[] a;
    static int n;
    
}
