use std::io::{self, BufRead}; fn get_lines() -> Vec { let stdin = io::stdin(); let lines: Vec = stdin.lock().lines().map(|l| l.unwrap()).collect(); return lines; } fn main(){ let s = &get_lines(); let n: i32 = s[0].parse().unwrap(); let a: Vec = s[1].split(' ').map(|x| x.parse().unwrap()).rev().collect(); let mut c = a[0]; for x in &a[1..] { if *x == c - 1 { c -= 1; } } println!("{}", n - (a[0] - c)); }