#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::(); let mut a = read_vec::(); a.sort(); let mut zero_count = a.iter().filter(|&&x| x == 0).count() as i64; if zero_count >= n as i64 - 1 { println!("Yes"); return; } let a = a.iter().filter(|&&x| x > 0).collect::>(); let diffs = (0..a.len() - 1) .map(|x| a[x + 1] - a[x]) .collect::>(); let g = diffs.iter().fold(diffs[0], |x, s| gcd(x, *s)); if diffs.iter().any(|&d| d == 0) { if a.iter().all(|&x| x == a[0]) { println!("Yes"); } else { println!("No"); } return; } debug!(g); for i in 1..a.len() { zero_count -= (a[i] - a[i - 1]) / g - 1; } if zero_count >= 0 { println!("Yes"); } else { println!("No"); } } fn gcd(a: i64, b: i64) -> i64 { if b == 0 { return a; } gcd(b, a % b) } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }