# coding: utf-8
# Your code here!
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:
          print("No")
          unko = "unko"
          break

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