import sys

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

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

main()