n = int(input())
a = list(map(int, input().split()))

top = a[0]
if top == 0:
    if a.count(0) == n:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

s = list(set(a))
if len(s) == 3 and len(a)%3 == 0 and a[int(len(a)/3)-1] != a[int(len(a)/3)] and a[int(len(a)*2/3)-1] != a[int(len(a)*2/3)]:
    print("Yes")
else:
    print("No")
