N = input()
num = input().split(" ")
ichi = int(-1)
ni = int(-1)
san = int(-1)
unko = str()
for i in range(int(N)):
  if int(num[i]) == ichi:
    pass
  else:
    if int(num[i]) == ni:
      pass
    else:
      if int(num[i]) == san:
        pass
      else:
        if ichi == -1:
          ichi = int(num[i])
        elif ni == -1:
          ni = int(num[i])
        elif san == -1:
          san = int(num[i])
        else:
          unko = "unko"
          break

if int(N) % 3 != 0 and ni != -1:
    unko = "unko"
if ni == -1 and int(num[0]) != 0:
    unko = "unko"
else:
    pass

if unko != "unko":
  print("Yes")
else:
  print("No")