import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); String []A = new String[N]; for(int i = 0; i < N; i++) { A[i] = scan.next(); } scan.close(); Arrays.sort(A); int cnt = 1; int max = 0; for(int i = 0; i < N - 1; i++) { if(A[i].equals(A[i + 1])) { cnt ++; if(max < cnt) { max = cnt; } }else { cnt = 1; } } int k = N - max; if(k >= max - 1) { System.out.println("YES"); }else { System.out.println("NO"); } } }