function solve(arr){
	var len = arr.length;
  if(len == 1){
  	var hoge = arr[0];
    if(hoge == 1){return "1"}else{return}
  }
  for(var i = len-1; i >= 0; i--){
  	if(arr[i] == i+1){
    	var newArray = arr.filter((el,ind)=>ind!=i)
      var result = solve(newArray);
      if(result!==undefined)return result + "\n" + (i + 1);
    }
  }
}
function Main(input){
	input = input.split("\n");
  var b = input[1].split(" ").map(a=>~~a);
  var result = solve(b);
  if(result !== undefined)return result;
  return "-1";
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3
1 2 1
`);