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 mut a = s[1].split(' ').map(|x| x.parse::().unwrap()).rev(); a.position(|x| x == n); let mut c = n - 1; for x in a { if x == c { c -= 1; } } println!("{}", c); }