"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[1].split(" ").map(Number)
    var a = 8
    var b = 2
    var c = (a & !b) | (!a & b);
    // var c =  ( a || b ) && !( a && b );

    for (let i = 0; i < data.length; i++) {
        let a
        let b
        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 (Number(a^b) !== data[i]) {
            // console.log([a^b , data[i]])
            console.log('No')
            return
        }
    }
    console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));