fn read_vec() -> Vec { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn main() { use std::collections::VecDeque; let nm:Vec = read_vec(); let ops:Vec = read_vec(); let mut sort:VecDeque = VecDeque::new(); for i in 0..nm[0] { sort.push_back(i+1); } for i in 0..ops.len() { let temp = sort.remove(ops[i]-1).unwrap(); sort.push_front(temp); } println!("{}", sort[0]); }