using System;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var aArray = Console.ReadLine().Split(' ');
        var bitArray = new List<string>();

        foreach(string aStr in aArray)
        {
            var aInt = int.Parse(aStr);
            bitArray.Add( Convert.ToString(aInt, 2));
        }

        var isSame = true;

        for (int i = 0; i < bitArray.Count; i++)
        {
            string beforeHutNum = i == 0 ? beforeHutNum = bitArray[bitArray.Count - 1] : bitArray[i - 1];
            string afterHutNum = i == bitArray.Count - 1 ? afterHutNum = bitArray[0] : afterHutNum = bitArray[i + 1];

            // 文字列の長いほうに合わせる
            var longer = beforeHutNum.Length > afterHutNum.Length ? beforeHutNum : afterHutNum;
            var shorter = longer.Equals(afterHutNum) ? beforeHutNum : afterHutNum;
            var result = "";
            var loop = longer.Length - shorter.Length;
            for (int j = 0; j < loop; j++)
            {
                shorter = "0" + shorter;
            }

            for (int k = 0; k < longer.Length; k++)
            {
                if (longer[k] == shorter[k])
                {
                    result = result + "0"; 
                }
                else
                {
                    result = result + "1";
                }
            }

            var longerResult = result.Length > bitArray[i].Length ? result : bitArray[i];
            var shorterResult = longer.Equals(result) ? bitArray[i] : result;
            var loopResult = longerResult.Length - shorterResult.Length;
            for (int j = 0; j < loopResult; j++)
            {
                shorterResult = "0" + shorterResult;
            }

            if (longerResult != shorterResult)
            {
                isSame = false;
            }

        }

        Console.WriteLine(isSame?"Yes":"No");
    }
}