use std::io::*; use std::collections::VecDeque; fn main() { let mut s = 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 mut cards: VecDeque = (1..=n).collect(); let _m: usize = itr.next().unwrap().parse().unwrap(); itr.map(|x| x.parse::().unwrap()).for_each(|i| { let buf = cards.remove(i - 1).unwrap(); cards.push_front(buf); }); println!("{}", cards[0]); }