output_description: Print `Yes` if there exists a sequence of colors of the hats that is
  consistent with the remarks of the cats; print `No` otherwise.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1 a_2 ... a_N
attempt: # 解説
  def solve():
      n = int(input())
      a = tuple(map(int, input().split()))
  
      # n匹全体でA色とする
      # aloneな猫: a_i = A-1
      # 同色がいる猫: a_i = A
  
      M = max(a)
      m = min(a)
  
      delta = M - m
      # 最大値と最小値の差
  
      if delta > 1:
          return False
          # 各猫視点の色数の差は2以上にはならない
      elif delta == 1:
          # alone,同色ありが混在
          # aloneな猫: a_i = A-1
          # 同色がいる猫: a_i = A
  
          x = a.count(m)
          # alone猫数,この猫だけでx色ある
  
          y = n - x
          # 同色いる猫数
          # 最低1色、最大でy//2色（2匹ずつに分けて、端数はどこかのグループに入れる）
  
          if x >= M:
              return False
              # x + y//2 = A
              # x = A - y//2 < A
  
          if (y - (M - x) * 2) not in {0, 1}:
              return False
              # x + y//2 = A
              # y//2 = A - x
              # y = (A - x) * 2 or (A - x) * 2 + 1
  
          return True
  
      else:
          # if delta == 0
          if all(a_ == n - 1 for a_ in a):
              return True
              # 全員alone=A-1=n-1
  
          if all(a_ * 2 <= n for a_ in a):
              return True
              # 全員同色がいる=A
              # ooxxzz -> A=3: 色の総数は各グループが2匹以上なので、A*2<=n
              # oooxxx -> A=2
  
          return False
  
      return True
  
  
  print("Yes" if solve() else "No")
  
problem_description: Statement
  
  There are N cats. We number them from 1 through N.
  
  Each of the cats wears a hat. Cat i says: "there are exactly a_i different
  colors among the N - 1 hats worn by the cats except me."
  
  Determine whether there exists a sequence of colors of the hats that is
  consistent with the remarks of the cats.
samples: [{"input": "3\n    1 2 2", "output": "Yes\n    \n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it\nis consistent with the remarks of the cats.\n\n* * *"}, {"input": "3\n    1 1 2", "output": "No\n    \n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same\ncolor. Also, from the remark of cat 2, we can see that cat 1 and 3 wear hats\nof the same color. Therefore, cat 1 and 2 wear hats of the same color, which\ncontradicts the remark of cat 3.\n\n* * *"}, {"input": "5\n    4 3 4 3 4", "output": "No\n    \n\n* * *"}, {"input": "3\n    2 2 2", "output": "Yes\n    \n\n* * *"}, {"input": "4\n    2 2 2 2", "output": "Yes\n    \n\n* * *"}, {"input": "5\n    3 3 3 3 3", "output": "No"}]