'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g).map(str => Number(str));
  const N = input.shift();
  let btn_num = 2;
  let result = -1;
  let count = 0;

  for(let i = 0; i < N; i++){
      if(input.indexOf(btn_num) > -1){
        btn_num = input.indexOf(btn_num) + 1;
        count++;
        if(btn_num === 1){
            result = count;
            break;
        }
      } else {
          break;
      }
  }
  console.log(result);
}

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