fun main(argc:Array<String>){
    val N = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{it.toInt()}
    var JD = false
    var C1:MutableList<Int> = mutableListOf()
    var C2:MutableList<Int> = mutableListOf()
    var tmp:MutableList<Int> = mutableListOf()
    var Z:MutableList<Int> = mutableListOf()
    var W:MutableList<Int> = mutableListOf()
    var ans:MutableList<Int> = mutableListOf()
    for(i in a.indices){
        println(i)
        var Mx:Int = if(i == (N-1))0 else i+1
        var Mn:Int = if(i == 0)N-1 else i-1
        C1.clear()
        C2.clear()
        ans.clear()
        tmp.clear()
        var TMP:Int = a[Mn]
        while(TMP != 0){
            C1.add(TMP%2)
            TMP/=2
        }
        println(C1)
        TMP = a[Mx]
        while(TMP != 0){
            C2.add(TMP%2)
            TMP/=2
        }
        var min = C1.size
        if(min<C2.size){
            Z = C1
            W = C2
            while(W.size != Z.size){
                Z.add(0)
            }
        }else{
            Z = C2
            W = C1
            while(W.size != Z.size){
                Z.add(0)
            }
        }

        for(k in W.indices){
            if(W[k] == Z[k]){
                ans.add(0)
            }else{
                ans.add(1)
            }
        }
        TMP = a[i]
        while(TMP != 0){
            tmp.add(TMP%2)
            TMP /=2
        }
        if(tmp.size < ans.size){
            while(tmp.size != ans.size){
                tmp.add(0)
            }
        }else{
            while(tmp.size != ans.size){
                ans.add(0)
            }
        }
        for(k in (ans.size-1) downTo 0){
            if(ans[k] != tmp[k])JD = true
        }
        if(JD){
            println("No")
            return
        }
        C1.clear()
        C2.clear()
        Z.clear()
        W.clear()
        tmp.clear()
        ans.clear()
    }

    if(!JD){
        println("Yes")
        return
    }
}