import java.util.*
import java.lang.*

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val counts = HashMap<Int, Int>();
    for (value in a) {
        counts.put(value, counts.getOrDefault(value, 0) + 1);
    }
    for (value in counts.values) {
        if (value != n / 3) {
            println("NO");
            return
        }
    }
    val keys = counts.keys.toList()
    if(keys[0] xor keys[1]==keys[2]){
        println("YES")
    }else{
        println("NO")
    }
}
