use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let m: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..m) .map(|_| itr.next().unwrap().parse::().unwrap() - 1) .collect(); let mut b: std::collections::VecDeque = (1..n + 1).collect(); for i in 0..m { let c = b.remove(a[i]).unwrap(); b.push_front(c); } println!("{}", b.get(0).unwrap()); }