n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
    print("Yes")
    exit()
if n%3!=0:
    print("No")
    exit()
if a[0]&a[1]&a[2]!=0:
    print("No")
    exit()
for i in range(n-3):
    if a[i]!=a[i+3]:
        print("No")
        exit()
print("Yes")
