fn main() { let stdin = std::io::read_to_string(std::io::stdin()).unwrap(); let mut stdin = stdin.split_ascii_whitespace(); let n: usize = stdin.next().unwrap().parse().unwrap(); let x: Vec = (0..n) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); use std::io::Write; let mut out = std::io::BufWriter::new(std::io::stdout().lock()); out.write_all(output(solve(x)).as_bytes()).unwrap(); } fn solve(x: Vec) -> u32 { let mut count_of = vec![0_u32; 1_000_001]; x.into_iter().for_each(|x| count_of[x as usize] += 1); match count_of .into_iter() .enumerate() .filter(|&(_, c)| c != 0) .map(|(i, _)| i as u32) .collect::>() .windows(2) .map(|x| x[1] - x[0]) .min() { Some(ans) => ans, None => 0, } } fn output(ans: u32) -> String { ans.to_string() + "\n" }