import sys

def main():
    n = int(input())-1
    nums = list(map(int,input().split()))
    bins = []
    for num in nums:
        bins.append(str(bin(num)[2:]))

    #print(bins)
    #[1(0), 10(1), 11(2)]
    for i in range(n):
        if i == 0:
            if int(str(int(bins[n])+int(bins[1])).replace("2","0")) == int(bins[0]):
                continue
            else:
                print("No")
                sys.exit()
        elif i == n:
            if int(str(int(bins[n-1])+int(bins[0])).replace("2","0")) == int(bins[n]):
                continue
            else:
                print("No")
                sys.exit()
        else:
            if int(str(int(bins[i-1])+int(bins[i+1])).replace("2","0")) == int(bins[i]):
                continue
            else:
                print("No")
                sys.exit()

    print("Yes")

main()