import Foundation

let numOfHats = Int(readLine()!)!
var numbers = readLine()!.componentsSeparatedByString(" ")
var maxCount = 0
var yes = true

// 2進数に変換する
for i in 0...numOfHats - 1 {
    numbers[i] = String(Int(numbers[i])!, radix: 2)
    let tmpCount = numbers[i].characters.count
    if maxCount < tmpCount {
        maxCount = tmpCount
    }
}

// 0埋めする
for i in 0...numOfHats - 1 {
    let numOfCharacters = numbers[i].characters.count
    if numOfCharacters == maxCount - 1 {
        numbers[i] = "0" + numbers[i]
    } else if numOfCharacters < maxCount-1 {
        for j in 0...maxCount - numOfCharacters {
            numbers[i] = "0" + numbers[i]
        }
    }
}

// 両隣の帽子の数の排他的論理和が、自分の数になるかチェックする
for i in 0...numOfHats - 1 {
    var comparedString = ""
    
    if i == 0 {
        for (bit1, bit2) in zip(numbers[numOfHats - 1].characters, numbers[1].characters) {
            if (bit1 == bit2) {
                comparedString = comparedString + "0"
            }
            if (bit1 != bit2) {
                comparedString = comparedString + "1"
            }
        }
    } else if i == numOfHats - 1 {
        for (bit1, bit2) in zip(numbers[numOfHats - 2].characters, numbers[0].characters) {
            if (bit1 == bit2) {
                comparedString = comparedString + "0"
            }
            if (bit1 != bit2) {
                comparedString = comparedString + "1"
            }
        }
    } else {
        for (bit1, bit2) in zip(numbers[i-1].characters, numbers[i+1].characters) {
            if (bit1 == bit2) {
                comparedString = comparedString + "0"
            }
            if (bit1 != bit2) {
                comparedString = comparedString + "1"
            }
        }
    }
    
    if comparedString != numbers[i] {
        yes = false
        break
    }
}

if yes {
    print("Yes")
} else {
    print("No")
}
