function Main(input) {
  var input = input.split("\n");
  var n = input[0];
  var b = input[1].split(" ");
  var a = new Array();
  var i = 0;
  var j = 1;
  var k = n -1;

  while (i < n) {
    if(b[i] > j) {
      return console.log(-1);
    }
    i++, j++;
  }
  var max = Math.max.apply(null, b);
  b.indexOf(max);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));