"use strict"
const pad = (num, length, str) => {
    return (new Array(length).fill(str).join('') + num).slice(-length);
}

function main(arg) {
    var data = arg.trim().split("\n")[1].split(" ").map(Number)

    for (let i = 0; i < data.length; i++) {
        let a
        let b
        let c = data[i]
        if (i+1 >= data.length) {
            a = data[0]
        } else {
            a = data[i+1]
        }
        if (i-1 < 0) {
            b = data[data.length - 1]
        } else {
            b = data[i-1]
        }
        if (xor(a, b) !== c) {
            console.log('No');
            return;
        }
    }
    console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function xor(a, b) {
    let aStr = a.toString(2)
    let bStr = b.toString(2)
    let k = Math.max(aStr.length, bStr.length)
    aStr = pad(aStr, k, 0)
    bStr = pad(bStr, k, 0)
    let aArr = aStr.split('')
    let bArr = bStr.split('')
    let tmp = []
    for (let i = 0; i < aArr.length; i++) {
        if ((Number(aArr[i]) + Number(bArr[i])) === 1) {
            tmp.push(1)
        } else {
            tmp.push(0)
        }
    }
    tmp.reverse()
    let ans = 0
    for (let i = 0; i < tmp.length; i++) {
        ans += Number(tmp[i]) * Math.pow(2, i)
    }
    return ans
}