// inputに入力データ全体が入る
function Main(input) {
  var noList = input.split("\n")[1].split(" ");
  var allZero = true;
  for(var i = 0; i < noList.length; i++){//すべてゼロ
    if(noList[i] != 0){
       allZero = false;
      break;
       }
  }
  if(allZero){
     console.log("Yes");
    return;
  }
  
  var zeroOrHigher = {
    "zero" : 0,
    "notZero" : 0
  };
  for(var i = 0; i < noList.length; i++){//ゼロがN/3個、ゼロ以外が2N/3個
    if(parseInt(noList[i]) == 0){
       zeroOrHigher["zero"]++;
       }else{
         zeroOrHigher["notZero"]++;
       }
  }
  if(zeroOrHigher["zero"] == noList.length / 3 && zeroOrHigher["notZero"] == noList.length * 2 / 3){
     console.log("Yes");
    return;
     }
  
  for(var i = 0; i < noList.length; i++){
    var one = parseInt(noList[i]);
    var tmpTwo = i + 1;
    if(tmpTwo >= noList.length){
       tmpTwo = 0;
    }
    var two = parseInt(noList[tmpTwo]);
    var tmpThree = i + 2;
    if(tmpThree >= noList.length){
       tmpThree = (i + 2) - noList.length;
    }
    var three = parseInt(noList[tmpThree]);
    var tmpFour = i + 3;
    if(tmpFour >= noList.length){
       tmpFour = (i + 3) - noList.length;
    }
    var four = parseInt(noList[tmpFour]);
    if(one == four && one ^ two ^ three == two ^ three ^ four){
       
    }else{
      console.log("No");
       return;
    }
  }
  console.log("Yes");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
