Problem:
Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.

The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;

fn main() {
  input! {
    n: usize,
    a_l: [usize; n]
  };

  let mut table = std::collections::HashMap::new();
  for a in a_l {
    let x = table.entry(a).or_insert(0);
    *x += 1;
  }

  if table.iter().count() > 3 {
    println!("No");
    std::process::exit(0);
  }

  for (&k1, &v1) in &table {
    for (&k2, &v2) in &table {
      if k1 == k2 && v1 < 2 {
        continue;
      }
      let k3 = k1 ^ k2;
      if let Some(&v3) = table.get(&k3) {
        let is_ok = if k1 == k2 && k2 == k3 {
          // 0, 0, 0
          n == v1
        } else if k1 == k2 {
          // 1, 1, 0
          v1 == v3 * 2 && v1 + v3 == n
        } else if k1 == k3 {
          // 1, 0, 1
          v1 == v2 * 2 && v1 + v2 == n
        } else if k2 == k3 {
          // 0, 1, 1
          v1 * 2 == v2 && v1 + v2 == n
        } else {
          // 1, 2, 3
          v1 == v2 && v2 == v3 && v1 + v2 + v3 == n
        };
        let res = if is_ok { "Yes" } else { "No" };
        println!("{}", res);
        std::process::exit(0);
      }
    }
  }
  println!("No");
}
*/

fn main() {
    let exe = "/tmp/bin9E3CF386";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";