#![allow(unused_imports, dead_code)] #![allow(unused_macros)] use proconio::{input, marker::{Chars, Usize1}}; // use std::cmp::{max, min, Reverse}; use std::mem::{swap}; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque, LinkedList}; use std::cmp::Ordering; 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"); } }