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

res=0
a_set=set(a)

if n % 3 ==0:
    if len(a_set) <= 3:
        print("Yes")
        exit()
else:
    if len(a_set) ==1:
        print("Yes")
        exit()
print("No")