import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); HashMap map = new HashMap(); for(int i = 0; i < N; i++){ final String input = sc.next(); if(!map.containsKey(input)){ map.put(input, 0); } map.put(input, map.get(input) + 1); } int[] array = new int[map.size()]; { int count = 0; for(final int value : map.values()){ array[count++] = value; } } Arrays.sort(array); //System.out.println(Arrays.toString(array)); int cur = array[0]; if(array.length == 1 && cur >= 2){ System.out.println("NO"); return; } for(int i = 1; i < array.length; i++){ if((cur + 1) < array[i]){ System.out.println("NO"); return; } cur += array[i]; } System.out.println("YES"); } }