n = int(input())
li = list(map(int, input().split()))
for i in range(1, n - 1):
    a = bin(li[i - 1])[2:]
    b = bin(li[i])[2:]
    c = bin(li[i + 1])[2:]
    if len(a) > len(b) and len(a) > len(c):
        b = b.zfill(len(a))
        c = c.zfill(len(a))
    elif len(b) > len(a) and len(b) > len(c):
        a = a.zfill(len(b))
        c = c.zfill(len(b))
    else:
        a = a.zfill(len(c))
        b = b.zfill(len(c))
    for j in range(len(a)):
        print(a[j], c[j], b[j])
        if a[j] == c[j]:
            if b[j] != '0':
                print('No')
                exit()
        else:
            if b[j] != '1':
                print('No')
                exit()
print('Yes')
