// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut mp = std::collections::BTreeMap::new();
    let mut vs = vec![];
    let mut cs = vec![0; n];
    let mut ci = 0;
    for _ in 0 .. n {
    	let a = get!();
        vs.push(a);
        if let Some(&i) = mp.get(&a) {
            cs[i] += 1;
            continue;
        }
        mp.insert(a, ci);
        cs[ci] = 1;
        ci += 1;
    }
    if ci > 3 {
        println!("No");
        return;
    }
    for i in 1 .. ci {
		if cs[i-1] != cs[i] {        
            println!("No");
            return;
        }
    }
    println!("Yes");
}