import tables
from strutils import split, parseInt
from sequtils import map, mapIt
from algorithm import sort

let
  N = stdin.readLine.parseInt
  a = stdin.readLine.split.map(parseInt)

var ct = initCountTable[int]()
for v in a:
  ct.inc(v)

proc isOK(): bool =
  var S = newSeq[tuple[key, val: int]](ct.len)
  for c in ct.pairs: S.add(c)
  S.sort(system.cmp)

  (ct.len == 1 and ct.hasKey(0)) or (
    N mod 3 == 0 and (
      (ct.len == 2 and ct.hasKey(0) and ct.largest.key != 0 and ct[0] == N div 3) or
      (ct.len == 3 and S[0].val == S[^1].val)
    )
  )

if isOK():
  echo "Yes"
else:
  echo "No"
