#![allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } macro_rules! chmax { ($a: expr, $b: expr) => { if $a < $b [ $a = $b; ] } } macro_rules! min { ($x: expr) => ($x); ($x: expr, $($z: expr),+) => (::std::cmp::min($x, min!($($z),*))); } macro_rules! max { ($x: expr) => ($x); ($x: expr, $($z: expr),+) => (::std::cmp::max($x, max!($($z),*))); } fn gcd(a: usize, b: usize) -> usize { if b == 0 { return a } gcd(b, a % b) } fn main() { input! { n: usize, a: [usize; n], } let mut c = vec![]; for x in a { if x != 0 { c.push(x); } } let k = c.len(); if k == 0 { println!("Yes"); return; } c.sort(); let mut d = vec![]; for i in 1..k { d.push(c[i] - c[i-1]); } let cnt = d.iter().filter(|&x| *x == 0).count(); if cnt > 0 { if cnt == k-1 { println!("Yes"); } else { println!("No"); } return; } let g = d.iter().fold(0, |g, x| gcd(g, *x)); let v = d.iter().fold(0, |tot, x| tot + x / g - 1); if v <= n - k { println!("Yes"); } else { println!("No"); } }