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

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val counts = HashMap<Int, Int>()
    if(n%3!=0){
        println("NO");
    }
    for (value in a) {
        val numSeen = counts[value] ?: 0
        counts[value] = numSeen + 1
    }
    for (value in counts.values) {
        if (value != n / 3 && value != 2 * n / 3 && value != n) {
            println("NO");
            return
        }
    }
    val keys = counts.keys.toList()
    var possible = false;
    if (keys.size == 3) {
        if (keys[0] xor keys[1] == keys[2]) {
            possible = true;
        }
    } else if (keys.size == 2) {
        if (counts[keys[0]] == 1) {
            if (keys[0] == 0) {
                possible = true
            }
        } else {
            if (keys[1] == 0) {
                possible = true
            }
        }
    } else if (keys.size == 3) {
        if (keys[0] == 0) {
            possible = true
        }
    }
    if (possible) {
        println("YES")
    } else {
        println("NO")
    }
}
