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)); if(array.length == 1 && array[0] >= 2){ System.out.println("NO"); return; }else if(array.length == 2){ if((array[0] - 1) > array[1]){ System.out.println("NO"); return; }else if((array[0] + 1) < array[1]){ System.out.println("NO"); return; } } int ok_count = array[0] + array[1]; for(int i = 2; i < array.length; i++){ if(ok_count + 1 < array[i]){ System.out.println("NO"); return; } ok_count += array[i]; } System.out.println("YES"); } }