fn main() { let stdin = std::io::read_to_string(std::io::stdin().lock()).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; std::io::stdout() .lock() .write_all(output(solve(x)).as_bytes()) .unwrap(); } fn solve(mut x: Vec) -> bool { x.sort_unstable(); x[0] != x[1] && x.windows(3).all(|x| x[0] + x[2] == x[1] << 1) } fn output(ans: bool) -> &'static str { match ans { true => "YES", false => "NO", } }