Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.

Help Yaroslav.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array. The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000) — the array elements.


-----Output-----

In the single line print "YES" (without the quotes) if Yaroslav can obtain the array he needs, and "NO" (without the quotes) otherwise.


-----Examples-----
Input
1
1

Output
YES

Input
3
1 1 2

Output
YES

Input
4
7 7 7 7

Output
NO



-----Note-----

In the first sample the initial array fits well.

In the second sample Yaroslav can get array: 1, 2, 1. He can swap the last and the second last elements to obtain it.

In the third sample Yarosav can't get the array he needs.

Difficulty: EASY

Solutions:
n = int(input())
s = input().split()
print('YES' if all((s.count(i) <= (n + 1) // 2 for i in s)) else 'NO')


n = int(input())
s = [0] * 1001
a = list(map(int, input().split()))
for i in range(n):
	s[a[i]] += 1
z = max(s)
if z > (n + 1) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
mas = list(map(int, input().split()))
mas2 = [0 for _ in range(1001)]
for i in mas:
	mas2[i] += 1
i = 0
for i in mas2:
	if i > (n + 1) / 2:
		print('NO')
		return
print('YES')


def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	counter = [0] * (max(a) + 1)
	for i in a:
		counter[i] += 1
	status = True
	for i in counter:
		if i > (n + 1) // 2:
			status = False
	if status:
		print('YES')
	else:
		print('NO')
main()


from collections import Counter
x = int(input())
k = list(map(int, input().split()))
if len(k) == 1:
	print('YES')
elif Counter(k).most_common(1)[0][1] <= len(k) // 2 and len(k) > 1 and (len(k) % 2 == 0):
	print('YES')
elif Counter(k).most_common(1)[0][1] <= len(k) // 2 + 1 and len(k) > 1 and (len(k) % 2 == 1):
	print('YES')
else:
	print('NO')


def gint():
	return int(input())

def gint_arr():
	return list(map(int, input().split()))

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
n = gint()
if n == 1:
	print('YES')
	exit()
a = gint_arr()
from collections import Counter
cnt = Counter(a)
for x in cnt.values():
	if x > int(n / 2) + n % 2:
		print('NO')
		exit()
print('YES')


n = int(input())
ls = list(map(int, input().split()))
ans = 'YES'
for i in ls:
	if ls.count(i) * 2 > n + 1:
		ans = 'NO'
print(ans)


import math
n = int(input())
numbers = [int(i) for i in input().split()]
for item in numbers:
	if numbers.count(item) > math.ceil(len(numbers) / 2):
		print('NO')
		break
else:
	print('YES')


import collections
n = int(input())
number = [int(x) for x in input().split(' ')]
number = collections.Counter(number)
if n % 2 == 0:
	if all((x <= n // 2 for x in number.values())):
		print('YES')
	else:
		print('NO')
elif all((x <= n // 2 + 1 for x in number.values())):
	print('YES')
else:
	print('NO')


while 1:
	try:
		n = int(input())
		a = list(map(int, input().split()))
		b = []
		for ele in a:
			if ele in b:
				continue
			else:
				b.append(ele)
		c = 1
		for ele in b:
			if a.count(ele) <= (n + 1) // 2:
				continue
			else:
				c = 0
				break
		if c == 1:
			print('YES')
		else:
			print('NO')
	except EOFError:
		break


import math
n = int(input())
arr = list(map(int, input().split()))
req = 0
if n == 1:
	print('YES')
else:
	for k in set(arr):
		req = max(req, arr.count(k))
	if n - req >= req - 1:
		print('YES')
	else:
		print('NO')


from collections import Counter
import math
n = int(input())
x = list(map(int, input().split()))
abc = Counter(x).most_common()
if abc[0][1] >= math.ceil(n / 2) + 1:
	print('NO')
else:
	print('YES')


from math import ceil
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
maxi = max(d.values())
if maxi <= ceil(n / 2):
	print('YES')
else:
	print('NO')


import statistics
from statistics import mode
n = int(input())
a = list(map(int, input().split()))
a = a.count(mode(a))
if a == 1:
	print('YES')
elif n % 2 == 0:
	if a <= n // 2:
		print('YES')
	else:
		print('NO')
elif a <= n // 2 + 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
	d[i] = d.get(i, 0) + 1
x = d.values()
p = n // 2
if n % 2 != 0:
	p += 1
if max(x) <= p:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input().split())
count = True
for i in s:
	if s.count(i) * 2 - 1 > n:
		count = False
		break
if count:
	print('YES')
else:
	print('NO')


n = int(input())
inp = input().split()
l = []
d = {}
for i in range(len(inp)):
	l.append(int(inp[i]))
	if l[i] not in d:
		d[l[i]] = 1
	else:
		d[l[i]] = d.get(l[i]) + 1
gmax = -1
val = -1
for num in d:
	if gmax < d.get(num):
		gmax = d.get(num)
		val = num
count = 0
for num in d:
	if val != num:
		count = count + d.get(num)
if count >= gmax - 1:
	print('YES')
else:
	print('NO')


def yaroslav():
	length = int(input())
	array = list(map(int, input().split()))
	if len(array) == 1:
		return 'YES'
	dic = {}
	if len(array) % 2 == 0:
		for i in range(len(array)):
			if array[i] not in dic:
				dic[array[i]] = 1
			else:
				dic[array[i]] += 1
				if dic[array[i]] > len(array) / 2:
					return 'NO'
	else:
		for i in range(len(array)):
			if array[i] not in dic:
				dic[array[i]] = 1
			else:
				dic[array[i]] += 1
				if dic[array[i]] == int(len(array) / 2) + 2:
					return 'NO'
	return 'YES'
A = yaroslav()
print(A)


import sys
import math
from sys import stdin, stdout

def sieve(N):
	primeNumbers = [True] * (N + 1)
	primeNumbers[0] = False
	primeNumbers[1] = False
	i = 2
	while i * i <= N:
		j = i
		if primeNumbers[j]:
			while j * i <= N:
				primeNumbers[j * i] = False
				j += 1
		i += 1
	return primeNumbers

def getPrime(N):
	primes = sieve(N)
	result = []
	for i in range(len(primes)):
		if primes[i]:
			result.append(i)
	return result

def factor(N):
	factors = []
	i = 1
	while i * i <= N:
		if N % i == 0:
			factors.append(i)
			if i != N // i:
				factors.append(N // i)
		i += 1
	return sorted(factors)

def reduceB(b):
	mod = 0
	for i in range(0, len(b)):
		mod = (mod * 10 + ord(b[i])) % 1000000007
	return mod

def gcd(a, b):
	if a < b:
		return gcd(b, a)
	if b == 0:
		return a
	return gcd(b, a % b)

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(input())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def arrSame(arr, n):
	for i in range(1, n):
		if arr[0] != arr[i + 1]:
			return False
	return True

def main():
	n = int(input())
	arr = get_ints_in_list()
	mp = {}
	for i in range(0, n):
		if arr[i] not in mp:
			mp[arr[i]] = 1
		else:
			mp[arr[i]] += 1
	mx = 0
	for (key, value) in mp.items():
		if mx < value:
			mx = value
	diff = n - mx
	if mx <= diff + 1:
		print('YES')
	else:
		print('NO')
main()


import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
for i in a:
	if a.count(i) > (n + 1) // 2:
		print('NO')
		break
else:
	print('YES')


n = int(input())
import collections
array = collections.Counter(map(int, input().split()))
for each in array.values():
	if each > (n + 1) / 2:
		print('NO')
		exit()
print('YES')


from math import ceil
n = int(input())
a = input().split()
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
for i in d:
	if d[i] > ceil(n / 2):
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
l = list(d.keys())
x = (n + 1) // 2
for i in l:
	if d[i] > x:
		print('NO')
		exit()
print('YES')


_ = input()
numbers = {}
size = 0
for num in input().split():
	if num in numbers:
		numbers[num] += 1
	else:
		numbers[num] = 1
	size += 1
half = size // 2 + size % 2
for value in numbers.values():
	if value > half:
		print('NO')
		exit()
print('YES')


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter
if Counter(arr).most_common(1)[0][1] > (n + 1) // 2:
	print('NO')
else:
	print('YES')


n = (int(input()) + 1) // 2
(t, p) = (input().split(), {})
for i in t:
	p[i] = p.get(i, 0) + 1
print('YNEOS'[max(p.values()) > n::2])


n = int(input())
a = [int(x) for x in input().split()]
for i in a:
	if a.count(i) * 2 > n + 1:
		print('NO')
		break
else:
	print('YES')


import statistics
n = int(input())
a = list(map(int, input().split()))
k = 0
ans = statistics.mode(a)
for i in range(n):
	if a[i] == ans:
		k += 1
h = n - k + 1
if k <= h:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(n):
	if a[i] in b:
		b[a[i]] += 1
	else:
		b[a[i]] = 1
if max(b.values()) <= (n + 1) // 2:
	print('YES')
else:
	print('NO')


from collections import defaultdict
n = int(input())
freq = defaultdict(int)
li = []
for _ in input().split():
	freq[int(_)] += 1
	li.append(int(_))
if n == 1:
	print('YES')
	exit()
else:
	m = 0
	for i in freq:
		if freq[i] > (n + 1) // 2:
			print('NO')
			exit()
	print('YES')


n = int(input())
l1 = list(map(int, input().split()))
d = {}
for x in l1:
	if x in d:
		d[x] = d[x] + 1
	else:
		d[x] = 1
max = 0
for x in d:
	if d[x] > max:
		max = d[x]
m = max
if n % 2 == 0:
	c = n // 2
else:
	c = n // 2 + 1
if m <= c:
	print('YES')
else:
	print('NO')


def yaroslav_and_permutations(n_int: int, numbers_list: list) -> str:
	times = dict()
	for each in numbers_list:
		if times.get(each, -1) == -1:
			times[each] = 1
		else:
			times[each] += 1
	max_seen = 0
	for (number, seen_time) in times.items():
		if seen_time > max_seen:
			max_seen = seen_time
	if max_seen <= (n_int + 1) // 2:
		return 'YES'
	else:
		return 'NO'
n = int(input())
numbers = list(map(int, input().split()))
print(yaroslav_and_permutations(n, numbers))


n = int(input())
arr = list(map(int, input().split()))
c = 0
if n % 2 == 0:
	c = int(n / 2)
else:
	c = int(n / 2) + 1
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
maxi = d[arr[0]]
for i in d:
	if d[i] > maxi:
		maxi = d[i]
if maxi > c:
	print('NO')
else:
	print('YES')


n = int(input())
arr = [int(x) for x in input().split(' ')]
mymap = {}
for item in arr:
	if item in mymap:
		mymap[item] += 1
	else:
		mymap[item] = 1
if any([x for x in mymap.values() if x > (n + 1) // 2]):
	print('NO')
else:
	print('YES')


from collections import Counter
n = int(input())
numbers = [int(c) for c in input().split()]
ans = 'YES' if Counter(numbers).most_common()[0][1] <= (n + 1) // 2 else 'NO'
print(ans)


from collections import Counter
n = int(input())
print('YES' if Counter([int(x) for x in input().split()]).most_common(1)[0][1] * 2 - 1 <= n else 'NO')


import sys
x = int(input())
y = input().split()
if x % 2 == 0:
	q = x // 2
else:
	q = x // 2 + 1
for i in y:
	if y.count(i) > q:
		print('NO')
		sys.exit(0)
print('YES')


import sys
n = int(input())
list1 = list(map(int, input().split()))
dict1 = {}
for i in list1:
	if i in dict1:
		dict1[i] += 1
	else:
		dict1[i] = 1
if n % 2 == 0:
	for i in dict1:
		if dict1[i] > n // 2:
			print('NO')
			sys.exit()
	print('YES')
else:
	for i in dict1:
		if dict1[i] > (n + 1) // 2:
			print('NO')
			sys.exit()
	print('YES')


n = int(input())
k = list(map(int, input().split()))
k.sort()
hash = {}
hash1 = {'r': 0, 'o': 0}
for i in k:
	if i in hash.keys():
		hash[i] = hash[i] + 1
	else:
		hash[i] = 1
max = 0
for i in hash.keys():
	if hash[i] > max:
		hash1['r'] = hash[i]
		max = hash[i]
	hash1['o'] += hash[i]
hash1['o'] = hash1['o'] - hash1['r']
if hash1['o'] >= hash1['r'] - 1:
	print('YES')
else:
	print('NO')


n = int(input())
arr = input().split()
trans = []
for i in arr:
	trans.append(int(i))
flag = False
my_set = set(trans)
for i in my_set:
	if trans.count(i) > (n + 1) / 2:
		flag = True
		break
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))

def t(arr):
	arr1 = set(arr)
	for i in arr1:
		if arr.count(i) > (n + 1) // 2:
			return 'NO'
	return 'YES'
print(t(arr))


n = int(input())
a = list(map(int, input().split()))
a.sort()
count = 1
for i in range(1, n):
	if a[i] == a[i - 1] and a.count(a[i]) > count:
		count += 1
	elif a.count(i) > count:
		count = a.count(i)
k = count
if k <= n // 2 and n % 2 == 0:
	print('YES')
elif k <= n // 2 + 1 and n % 2 != 0:
	print('YES')
else:
	print('NO')


n = int(input())
k = [0] * n
l = [0] * 1001
k = list(map(int, input().split()))
for _ in range(n):
	l[k[_] - 1] += 1
k = max(l)
if k > (n + 1) // 2:
	print('NO')
else:
	print('YES')


from math import ceil
n = int(input())
lst = list(map(int, input().split()))
for i in lst:
	if lst.count(i) > ceil(n / 2):
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
st = set(a)
for i in st:
	if a.count(i) > int((n + 1) / 2):
		print('NO')
		exit()
print('YES')


import sys
import math
n = int(sys.stdin.readline())
an = [int(x) for x in sys.stdin.readline().split()]
d = dict()
for i in an:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
vmax = 0
for i in list(d.keys()):
	if d[i] > vmax:
		vmax = d[i]
if vmax <= (n + 1) / 2:
	print('YES')
else:
	print('NO')


import collections
n = int(input())
l = list(map(int, input().strip().split()))
d = {}
c = collections.Counter(l)
k = c.most_common(1)
if n // 2 <= n - k[0][1]:
	print('YES')
else:
	print('NO')


from math import *
from collections import *
from sys import *
import string
import re
t = stdin.readline
p = stdout.write

def GI():
	return map(int, t().strip().split())

def GS():
	return map(str, t().strip().split())

def IL():
	return list(map(int, t().strip().split()))

def SL():
	return list(map(str, t().strip().split()))
n = int(t())
a = IL()
b = (n + 1) // 2
f = 1
for i in set(a):
	if a.count(i) > b:
		f = 0
		print('NO')
		break
if f:
	p('YES\n')


from collections import Counter

def main():
	n = int(input())
	c = Counter(input().split())
	print(('NO', 'YES')[max(c.values()) * 2 < n + 2])
main()


from collections import Counter
if 1 + int(input()) < 2 * max(Counter(map(int, input().split())).values()):
	print('NO')
else:
	print('YES')


n = int(input())
a = input()
a = a.split()
c = 0
for i in range(n):
	a[i] = int(a[i])
for i in range(n - 1):
	if a.count(a[i]) > c:
		c = a.count(a[i])
if n >= 2 * c - 1:
	print('YES')
else:
	print('NO')


x = int(input())
a = list(map(int, input().split()))
r = list(set(a))
k = 0
if x % 2 == 1:
	t = x // 2 + 1
else:
	t = x // 2
for i in range(len(r)):
	r1 = a.count(r[i])
	if r1 > t:
		print('NO')
		k = 1
		break
if k == 0:
	print('YES')


inp = int(input())
lis = list(map(int, input().split()))
unique = set(lis)
point = 0
if inp == 1:
	print('YES')
	exit()
for i in unique:
	if lis.count(i) > round(len(lis) / 2):
		print('NO')
		point = 1
		break
if point == 0:
	print('YES')


import sys
f = sys.stdin
n = int(f.readline().strip())
a = [int(i) for i in f.readline().strip().split()]
cnt = dict.fromkeys(a)
for i in cnt:
	cnt[i] = a.count(i)
if (sum(cnt.values()) - max(cnt.values()) < sum(cnt.values()) // 2 or a.count(a[0]) == len(a)) and len(a) >= 2:
	print('NO')
else:
	print('YES')


def num_check(num_list, num_cnt):
	global flag
	global list_of_numbers
	num_list = num_list.split(' ')
	if len(num_list) != num_cnt:
		print('\nNumber list out of bounds. Expected {} numbers.'.format(num_cnt))
		return
	for i in num_list:
		if '.' in i:
			print('\nEnter an integer.\n')
			return
		try:
			num = int(i)
			if num not in list_of_numbers.keys():
				list_of_numbers[num] = 1
			else:
				list_of_numbers[num] += 1
		except:
			if i != ' ':
				print('\nEnter the numbers separated by a space.')
				return
			else:
				pass
	flag = 1

def selection_sort():
	global list_of_numbers
	list_of_numbers = list(list_of_numbers.items())
	for i in range(len(list_of_numbers) - 1):
		for j in range(i + 1, len(list_of_numbers)):
			if list_of_numbers[i][1] < list_of_numbers[j][1]:
				(list_of_numbers[j], list_of_numbers[i]) = (list_of_numbers[i], list_of_numbers[j])
flag = 0
list_of_numbers = {}
num_cnt = int(input())
while flag == 0:
	num_list = input()
	num_check(num_list, num_cnt)
selection_sort()
highest_freq = list_of_numbers[0][1]
if num_cnt - highest_freq >= round(num_cnt // 2):
	print('YES')
else:
	print('NO')


from collections import Counter

def main():
	n = int(input())
	array = Counter(map(int, input().split()))
	if n >= 2 * max(array.values()) - 1:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
m = list(map(int, input().split()))
m1 = set(m)
if len(m) % 2 == 0:
	s = len(m) // 2
else:
	s = len(m) // 2 + 1
if len(m) != 1:
	for i in m1:
		if m.count(i) > s:
			print('NO')
			break
		elif m.count(i) == len(m):
			print('NO')
			break
	else:
		print('YES')
else:
	print('YES')


from math import ceil
n = int(input())
a = [int(i) for i in input().split()]
b = dict()
for i in a:
	if i not in b:
		b.update({i: a.count(i)})
x = 0
for i in b:
	if b[i] > ceil(n / 2):
		x = 1
		break
if x:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
flag = 1
for i in set(l):
	if n % 2 == 0 and l.count(i) > n // 2:
		print('NO')
		flag = 0
		break
	elif n % 2 != 0 and l.count(i) > n // 2 + 1:
		print('NO')
		flag = 0
		break
if flag == 1:
	print('YES')


n = int(input())
L = [int(i) for i in input().split()]
S = set(L)
flag = 0
for i in S:
	if L.count(i) > (n + 1) // 2:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if l[i] not in d:
		d[l[i]] = 1
	else:
		d[l[i]] = d[l[i]] + 1
all_values = d.values()
max_value = max(all_values)
if max_value > (n + 1) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
a = [int(x) for x in input().split()]
ans = ''
c = 0
num = 0
if n == 1:
	print('YES')
else:
	for i in range(n):
		b = a.count(a[i])
		if b > c:
			c = b
			num = a[i]
	c1 = 0
	for i in range(n):
		if a[i] != num:
			c1 += 1
	if c <= c1 + 1:
		print('YES')
	else:
		print('NO')


def arr_inp():
	return [int(x) for x in input().split()]
import math as m
n = int(input())
a = arr_inp()
dic = {}
for i in range(n):
	if str(a[i]) not in dic:
		dic[str(a[i])] = 1
	else:
		dic[str(a[i])] += 1
if max(dic.values()) > m.ceil(n / 2):
	exit(print('NO'))
print('YES')


n = int(input())
l = list(input().split())
ans = 'YES'
for i in set(l):
	if l.count(i) * 2 - 1 > n:
		ans = 'NO'
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
b = [0] * 1001
for i in a:
	b[i] += 1
if max(b) <= n // 2 + (n % 2 + 1) // 2:
	print('YES')
else:
	print('NO')


import math
N = int(input())
numbers = list(map(int, input().split()))
set_of_numbers = list(set(numbers))
countr = [None] * len(set_of_numbers)
for i in range(len(set_of_numbers)):
	countr[i] = numbers.count(set_of_numbers[i])
if max(countr) > math.ceil(N / 2):
	print('NO')
else:
	print('YES')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
arr = list(map(int, input().split()))
count = {}
max_count = 0
for el in arr:
	count[el] = count.get(el, 0) + 1
	if count[el] > max_count:
		max_count = count[el]
if max_count > (n + 1) // 2:
	print('NO')
else:
	print('YES')


from collections import defaultdict
N = int(input())
array = [int(x) for x in input().split()]

def stuff(N, array):
	L = N - int(N / 2)
	d = defaultdict(int)
	for x in array:
		d[x] += 1
		if d[x] > L:
			return False
	return True
print('YES' if stuff(N, array) else 'NO')


import statistics
from statistics import mode
a = int(input())
b = list(map(int, input().split()))
c = mode(b)
d = b.count(c)
if (a + 1) // 2 >= d:
	print('YES')
else:
	print('NO')


t = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 1
maxx = 1
for i in range(1, t):
	if l[i] == l[i - 1]:
		cnt += 1
		maxx = max(cnt, maxx)
	else:
		cnt = 1
if maxx <= (t + 1) / 2:
	print('YES')
else:
	print('NO')


import math
n = int(input())
b = [0] * 1001
a = list(map(int, input().split()))
for i in a:
	b[i] += 1
if max(b) <= math.ceil(n / 2):
	print('YES')
else:
	print('NO')


import math
n = int(input())
arr = input()
l = list(map(int, arr.split(' ')))
hashmap = {}
for i in l:
	if i in hashmap:
		hashmap[i] = hashmap[i] + 1
	else:
		hashmap[i] = 1
flag = False
for key in hashmap:
	if hashmap[key] > math.ceil(n / 2.0):
		flag = True
if flag == True:
	print('NO')
else:
	print('YES')


from collections import Counter
x = input()
arr = list(map(int, input().split(' ')))
callValues = Counter(arr)
computeVal = (len(arr) + 1) // 2
dec = False
for x in callValues:
	if callValues[x] > computeVal:
		dec = True
		break
if not dec:
	print('YES')
else:
	print('NO')


n = int(input())
li = list(map(int, input().split()))
f = 1
if n == 1:
	print('YES')
	exit()
for i in li:
	if li.count(i) > (n + 1) // 2:
		f = 0
		break
print('YES') if f else print('NO')


from math import ceil
n = int(input())
arr = list(map(int, input().split()))
freq = [0] * 1005
for ele in arr:
	freq[ele] += 1
flag = 0
for ele in freq:
	if ele > ceil(n / 2):
		flag = 1
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
array = list(map(int, input().split()))
a__ = []
for i in array:
	a = 0
	for j in range(n):
		if i == array[j]:
			a += 1
	a__.append(a)
max_ = max(a__)
if n % 2 == 0:
	if n / 2 >= max_:
		print('YES')
	else:
		print('NO')
elif n / 2 + 1 >= max_:
	print('YES')
else:
	print('NO')


import sys
from math import *
input = sys.stdin.buffer.readline
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
mc = 0
count = 1
for i in range(n - 1):
	if arr[i] == arr[i + 1]:
		count += 1
	else:
		if mc < count:
			mc = count
		count = 1
if mc < count:
	mc = count
if int(ceil(n / 2)) >= mc:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
A = input().split()
B = set(A)
if n % 2 == 0:
	limit = n // 2
else:
	limit = n // 2 + 1
for i in B:
	if A.count(i) > limit:
		print('NO')
		sys.exit(0)
print('YES')


n = int(input())
a = [0 for i in range(1001)]
m = map(int, input().split())
for k in m:
	a[k] += 1
maxe = n // 2 + n % 2
res = True
for i in range(len(a)):
	if a[i] > maxe:
		res = False
if res:
	print('YES')
else:
	print('NO')


n = int(input())
l1 = [int(num) for num in input().split(' ')]
l2 = list(set(l1))
l3 = []
for i in l2:
	l3.append(l1.count(i))
if n == 1:
	print('YES')
elif len(l2) == 1:
	print('NO')
elif sum(l3) % 2 == 0:
	if max(l3) <= sum(l3) // 2:
		print('YES')
	else:
		print('NO')
elif max(l3) <= sum(l3) // 2 + 1:
	print('YES')
else:
	print('NO')


from collections import Counter
n = int(input())
lst = list(map(int, input().split()))
dictt = Counter(lst)
for i in dictt.keys():
	if dictt[i] > (n + 1) // 2:
		print('NO')
		exit()
print('YES')


a = int(input())
l = list(map(int, input().split()))
d = dict()
s = set()
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
	s.add(i)
flag = False
for i in s:
	sum = 0
	for j in d:
		sum += d[j]
	sum -= d[i]
	if d[i] - sum > 1:
		flag = True
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
l = [int(ele) for ele in input().split()]
d = {}
for e in l:
	d[e] = d.get(e, 0) + 1
m = max(d.values())
if n % 2 == 0:
	if m > n / 2:
		print('NO')
	else:
		print('YES')
else:
	a = n / 2 + 0.5
	if m > a:
		print('NO')
	else:
		print('YES')


from collections import Counter
import math
n = int(input())
a = [int(i) for i in input().split()]
a = Counter(a)
b = [*a.values()]
f = 0
for i in b:
	if i > math.ceil(n / 2):
		f = 1
		break
if f:
	print('NO')
else:
	print('YES')


import math
n = int(input())
l = list(map(int, input().split()))
maj = l[0]
count = 1
for i in range(1, n):
	if l[i] == maj:
		count += 1
	elif count == 0:
		maj = l[i]
		count += 1
	else:
		count -= 1
count = 0
for i in range(n):
	if l[i] == maj:
		count += 1
if count > math.ceil(n / 2):
	print('NO')
else:
	print('YES')


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
mydict = dict()
for i in Arr:
	mydict[i] = mydict.get(i, 0) + 1
maxi = n // 2 + (n & 1)
for i in mydict:
	if mydict[i] > maxi:
		print('NO')
		exit()
print('YES')


n = int(input())
l = list(map(int, input().split()))
b = True
if n == 2:
	if l[0] == l[1]:
		b = False
if n > 2:
	for i in range(n):
		count = 0
		for j in range(n):
			if l[i] == l[j]:
				count += 1
		if n < 2 * count - 1:
			b = False
if b:
	print('YES')
else:
	print('NO')


def perms(dic, n):
	for ele in dic:
		if dic[ele] > (n + 1) // 2:
			return 'NO'
	return 'YES'
n = int(input())
l = list(map(int, input().split()))
dic = {}
for i in range(n):
	if l[i] not in dic:
		dic[l[i]] = 1
	else:
		dic[l[i]] += 1
print(perms(dic, n))


import math
b = int(input())
v = 0
max = -99999
a = [int(s) for s in input().split()]
c = set()
for i in range(0, b):
	c.add(a[i])
c = list(c)
for i in range(0, len(c)):
	v = a.count(c[i])
	if v > max:
		max = v
if max <= math.ceil(b / 2):
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
n = int(stdin.readline().rstrip())
arr = [0] * 10005
array = list(map(lambda i: int(i), stdin.readline().rstrip().split()))

def solve():
	for i in array:
		arr[i] += 1
		if arr[i] > (n + 1) // 2:
			stdout.write('NO' + '\n')
			return 0
	stdout.write('YES' + '\n')
	return 0
solve()


number = int(input())
numbers = list(map(int, input().split()))
d = {}
printyes = True
for num in numbers:
	d[num] = d.get(num, 0) + 1
	if d[num] > (number + 1) / 2:
		print('NO')
		printyes = False
		break
if printyes:
	print('YES')


n = int(input())
array = list(map(int, input().split()))
quantidadeDeNum = {}
for i in range(0, n):
	if array[i] in quantidadeDeNum:
		quantidadeDeNum[array[i]] += 1
	else:
		quantidadeDeNum[array[i]] = 1
da = True
for x in quantidadeDeNum.values():
	if x >= n / 2 + 1:
		da = False
		break
if da or n == 1:
	print('YES')
else:
	print('NO')


n = int(input())
arr = [int(i) for i in input().split()]
freq = {}
for elem in arr:
	if elem in freq:
		freq[elem] += 1
	else:
		freq[elem] = 1
temp = freq[max(freq, key=lambda x: freq[x])]
if n % 2 == 1:
	n += 1
if temp > n // 2 and n > 2:
	print('NO')
elif len(arr) == 2 and arr[1] == arr[0]:
	print('NO')
else:
	print('YES')


from collections import Counter
import math
n = int(input())
arr = list(map(int, input().split()))
c = Counter(arr)
(k, v) = max(c.items(), key=lambda x: x[1])
if n % 2 == 0:
	if v <= n // 2:
		print('YES')
	else:
		print('NO')
elif v <= math.ceil(n / 2):
	print('YES')
else:
	print('NO')


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
k = max(d.values())
if n == 1:
	print('YES')
	exit()
h = n - k + 1
if k <= h:
	print('YES')
else:
	print('NO')


import math
t = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 1
count = 1
for i in range(1, len(l), 1):
	if l[i] == l[i - 1]:
		sum += 1
		if sum > count:
			count = sum
	else:
		sum = 1
if count <= (t + 1) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
m = {}
for i in arr:
	if i in m:
		m[i] += 1
	else:
		m[i] = 1
f = True
for i in m:
	if m[i] > (n + 1) // 2:
		print('NO')
		f = False
if f:
	print('YES')


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def valid(row, col, rows, cols, rcross, lcross):
	return rows[row] == 0 and cols[col] == 0 and (rcross[col + row] == 0) and (lcross[col - row] == 0)

def div(n):
	tmp = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			cnt = 0
			while n % i == 0:
				n = n // i
				cnt += 1
			tmp.append((i, cnt))
	if n > 1:
		tmp.append((n, 1))
	return tmp

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		flag = True
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				flag = False
				break
		return flag

def s(b):
	ans = []
	while b > 0:
		tmp = b % 10
		ans.append(tmp)
		b = b // 10
	return ans

def main():
	n = ii()
	arr = li()
	if n == 1:
		print('YES')
	else:
		sett = set(arr)
		d = defaultdict(int)
		for i in range(n):
			d[arr[i]] += 1
		flag = 1
		for i in sett:
			if n - d[i] < d[i] - 1:
				flag = 0
				break
		if flag:
			print('YES')
		else:
			print('NO')
main()


n = int(input())
a = list(map(int, input().split()))
cnts = {}
yep = False
for i in range(len(a)):
	cnts[a[i]] = a.count(a[i])
for v in cnts.values():
	if v <= (n + 1) / 2:
		yep = True
	else:
		yep = False
		print('NO')
		break
if yep:
	print('YES')


import sys
n = int(input(''))
lst = list(map(int, input().split()))
dic = {}
for item in lst:
	if item not in dic:
		dic[item] = 1
	else:
		dic[item] += 1
for key in dic:
	if dic[key] >= int(len(lst)) / 2 + 1:
		print('NO')
		sys.exit()
print('YES')


n = int(input())
myList = list(map(int, input().split()))
mx = 0
for i in range(len(myList)):
	mx = max(mx, myList.count(myList[i]))
if mx > (len(myList) + 1) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
nums = [int(i) for i in input().split()]
flag = True
for i in nums:
	len_i = nums.count(i)
	len_other = len(nums) - len_i
	if len_i - len_other > 1:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
d = {}
k = 0
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
flag = 0
for j in a:
	if d[j] > (n + 1) // 2:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
m = list(map(int, input().split()))
for i in m:
	a = m.count(i)
	if n % 2 == 0:
		if a > n // 2:
			print('NO')
			exit()
	elif a > (n + 1) // 2:
		print('NO')
		exit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
else:
	x = a.count(1)
	for i in range(len(a)):
		if a.count(a[i]) > x:
			x = a.count(a[i])
	if x + (x - 1) <= n:
		print('YES')
	else:
		print('NO')


from collections import Counter
n = int(input())
c = Counter([int(i) for i in input().split()])
maxtime = c.most_common()[0][1]
if n >= 2 * maxtime - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
m = max(a)
c = [0 for i in range(m + 1)]
for i in a:
	c[i] += 1
for i in c:
	if i > (n + 1) // 2:
		print('NO')
		break
else:
	print('YES')


from math import ceil
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
else:
	d = dict()
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	flag = True
	for (k, v) in d.items():
		if v > ceil(n / 2):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
l = list(map(int, input().split()))
ans = [0 for i in range(1001)]
for i in l:
	ans[i] += 1
f = 0
for i in range(1, 1001):
	if ans[i] > (n + 1) // 2:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')


import math
n = int(input())
line = list(map(int, input().split()))
ch = math.ceil(n / 2)
lis = [0] * 1001
flag = 0
for k in line:
	lis[k] = lis[k] + 1
	if lis[k] > ch:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
l = [int(i) for i in input().split()]
c = set(l)
d = 0
e = 1
flag = 0
for i in c:
	if l.count(i) > d:
		d = l.count(i)
if n == 2:
	if d > 1:
		flag = 1
		if flag > 0:
			print('NO')
		elif flag == 0:
			print('YES')
	else:
		print('YES')
elif n == 1:
	print('YES')
else:
	for i in range(3, len(l) + 1):
		if i % 2 != 0:
			e = e + 1
	if d > e:
		print('NO')
	else:
		print('YES')


n = int(input())
q = [0] * 1005
f = 1
a = list(map(int, input().split()))
for i in range(n):
	q[a[i]] += 1
	if q[a[i]] > n // 2 + n % 2:
		f = 0
if f:
	print('YES')
else:
	print('NO')


from collections import Counter
n = int(input())
t = (n + 1) // 2
l = Counter(list(map(int, input().split())))
if max(l.values()) > t:
	print('NO')
else:
	print('YES')


import math

def yaro(n, arr):
	if n == 1:
		return 'YES'
	if n == 2:
		if arr[0] != arr[1]:
			return 'YES'
		else:
			return 'NO'
	if n == 3:
		if arr[0] != arr[1] or arr[1] != arr[2] or arr[0] == arr[2]:
			return 'YES'
		else:
			return 'NO'
	l = [0] * 1001
	limit = math.ceil(n / 2)
	for i in range(n):
		l[arr[i]] += 1
	for i in l:
		if i > limit:
			return 'NO'
	return 'YES'
n = int(input())
arr = list(map(int, input().split()))
print(yaro(n, arr))


from collections import *
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
f = 1
for v in c.values():
	if v >= (n + 1) // 2 + 1:
		f = 0
if f == 1:
	print('YES')
else:
	print('NO')


from functools import reduce
from collections import Counter
import time
import datetime

def time_t():
	print('Current date and time: ', datetime.datetime.now())
	print('Current year: ', datetime.date.today().strftime('%Y'))
	print('Month of year: ', datetime.date.today().strftime('%B'))
	print('Week number of the year: ', datetime.date.today().strftime('%W'))
	print('Weekday of the week: ', datetime.date.today().strftime('%w'))
	print('Day of year: ', datetime.date.today().strftime('%j'))
	print('Day of the month : ', datetime.date.today().strftime('%d'))
	print('Day of week: ', datetime.date.today().strftime('%A'))

def ip():
	return int(input())

def sip():
	return input()

def mip():
	return map(int, input().split())

def mips():
	return map(str, input().split())

def lip():
	return list(map(int, input().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)
n = ip()
arr = lip()
if n == 1:
	print('YES')
else:
	z = (n + 1) // 2
	k = set(arr)
	flag = 0
	for item in k:
		if arr.count(item) <= z:
			flag = 0
		else:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
arr = list(map(int, input().split()))
counts = dict()
for i in arr:
	if i in counts:
		counts[i] += 1
	else:
		counts[i] = 1
bad = False
for i in list(counts.values()):
	if i > (n + 1) / 2:
		bad = True
		break
if not bad:
	print('YES')
else:
	print('NO')


n = int(input())
r = 0
l = list(map(int, input().split()))
a = len(l) // 2
if len(l) % 2 != 0:
	a = len(l) // 2 + 1
p = set(l)
for i in p:
	c = l.count(i)
	if c <= a:
		r += 1
if r == len(p):
	print('YES')
else:
	print('NO')


n = int(input())
li = list(map(int, input().split()))
ans = 'YES'
for el in li:
	if li.count(el) * 2 > n + 1:
		ans = 'NO'
		break
print(ans)


import sys
import heapq
from collections import Counter

def main(arr):
	counts = max(Counter(arr).values())
	rest = len(arr) - counts
	if rest >= counts - 1:
		print('YES')
	else:
		print('NO')
arr = []
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	arr = list(map(int, line.strip().split()))
main(arr)


n = int(input())
lst = [int(x) for x in input().split()]
(cur, cnt) = (0, 0)
for i in lst:
	if i == cur:
		cnt += 1
	elif cnt == 0:
		(cur, cnt) = (i, 1)
	else:
		cnt -= 1
cnt = 0
for i in lst:
	if i == cur:
		cnt += 1
print('YES' if cnt + (cnt - 1) <= n else 'NO')


n = int(input())
m = list(map(int, input().split()))
a = []
for i in set(m):
	a.append(m.count(i))
print(['NO', 'YES'][max(a) <= n // 2 + 1 * (n % 2 != 0)])


def main():
	N = int(input())
	arr = list(map(int, input().split()))
	cnt = 1
	max_cnt = 0
	i = 0
	dp = [0 for _ in range(1001)]
	for x in arr:
		dp[x] += 1
	max_cnt = max(dp)
	if max_cnt <= (N + 1) // 2:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
l = list(map(int, input().split()))
try:
	for j in set(l):
		if l.count(j) >= n // 2 + 2 and n % 2 != 0:
			raise Exception
		elif l.count(j) >= n // 2 + 1 and n % 2 == 0:
			raise Exception
except Exception as e:
	print('NO')
else:
	print('YES')


def main():
	n = int(input())
	l = [-2] * 1001
	for x in map(int, input().split()):
		l[x] += 2
	print(('NO', 'YES')[max(l) < n])
main()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
n = I()
arr = L()
if n == 1:
	print('YES')
else:
	st = list(set(arr))
	if len(st) == 1:
		print('NO')
	else:
		lis = []
		for i in st:
			lis.append(arr.count(i))
		mx = 0
		c = 0
		for i in lis:
			if i > mx:
				c += mx
				mx = i
			else:
				c += i
		if c >= mx - 1:
			print('YES')
		else:
			print('NO')


from math import ceil
n = int(input().strip())
lst = list(map(int, input().strip().split()))
count_lst = []
lst.sort()
i = 0
while i < n:
	count = lst.count(lst[i])
	count_lst.append(count)
	i += count
max_count = max(count_lst)
if max_count > ceil(n / 2):
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
s = list(set(l))
if n % 2 == 0:
	for i in s:
		if l.count(i) > n // 2:
			print('NO')
			break
	else:
		print('YES')
else:
	for i in s:
		if l.count(i) > n // 2 + 1:
			print('NO')
			break
	else:
		print('YES')


input()
get = lambda : list(map(int, input().split()))
l = get()
if len(l) == 1:
	print('YES')
	exit()
from collections import Counter
c = Counter(l)
s = c.most_common(1)[0][1]
if s - 1 <= len(l) - s:
	print('YES')
else:
	print('NO')


import math
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = 1
for i in range(n):
	if cnt[a[i]] > math.ceil(n / 2):
		ans = 0
		break
if (len(set(a)) > 1 or len(a) == 1) and ans == 1:
	print('YES')
else:
	print('NO')


n = input()
s = input()
a = s.split()
for i in range(len(a)):
	a[i] = int(a[i])
length = len(a)
max = 0
for i in a:
	c = a.count(i)
	if c > max:
		max = c
if max - 1 > length - max:
	print('NO')
else:
	print('YES')


n = int(input())
c = {}
for x in (int(x) for x in input().split()):
	c[x] = 1 if x not in c else c[x] + 1
val = sum((1 for x in c if c[x] > (n + 1) // 2))
print('NO' if val else 'YES')


def yar(dict, n):
	for e in dict.keys():
		if dict.get(e) > (n + 1) // 2:
			return 'NO'
	return 'YES'
n = int(input())
L = list(map(int, input().split()))
dict = {}
for i in range(0, len(L)):
	if L[i] not in dict.keys():
		dict[L[i]] = 1
	else:
		dict[L[i]] += 1
print(yar(dict, n))


n = int(input())
arr = [int(i) for i in input().split(' ')]
flag = 0
set_A = set(arr)
for x in set_A:
	if arr.count(x) > int((n + 1) / 2):
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(i) for i in input().split()]
if n == 1:
	print('YES')
elif n == 2:
	print('YES' if l[0] != l[1] else 'NO')
else:
	f = 1
	from collections import Counter
	c = Counter(l)
	for i in c:
		if n & 1:
			k = n // 2
			if c[i] > k + 1:
				f = 0
				break
		else:
			k = n // 2
			if c[i] > k:
				f = 0
				break
	print('YES' if f else 'NO')


from collections import Counter
from math import ceil

def main():
	n = int(input())
	a = input().split()
	number_count = Counter(a)
	for count in number_count.values():
		if count > ceil(n / 2):
			return 'NO'
	return 'YES'
print(main())


n = int(input())
arr = list(map(int, input().split()))
counts = [0] * 1001
for x in arr:
	counts[x] += 1
mx = index = 0
for i in range(len(counts)):
	if counts[i] > mx:
		mx = counts[i]
		index = i
su = 0
for i in range(len(counts)):
	if i != index:
		su += counts[i]
if su >= counts[index] - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
d = {}
flag = True
for ele in a:
	d[ele] = d.get(ele, 0) + 1
for val in d.values():
	if val > (n + 1) // 2:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


from collections import Counter as c
a = int(input())
b = c(map(int, input().split()))
print('YES' if b.most_common(1)[0][1] <= (a + 1) // 2 else 'NO')


from collections import Counter
import math
n = int(input())
c = Counter([x for x in input().split()])
if n == 1:
	print('YES')
elif len(c) >= 2:
	for x in c:
		if c[x] > math.ceil(n / 2):
			print('NO')
			break
	else:
		print('YES')
else:
	print('NO')


n = int(input())
arr = [int(x) for x in input().split()]
valid = True
for i in range(n):
	c = 0
	for j in range(i, n):
		if arr[i] == arr[j]:
			c += 1
	if n < 2 * c - 1:
		valid = False
		break
if valid:
	print('YES')
else:
	print('NO')


N = int(input())
a = [0 for i in range(1000)]
s = [int(x) for x in input().split()]
for i in s:
	a[i - 1] += 1
m = (N + 1) // 2
for j in a:
	if j > m:
		print('NO')
		exit()
print('YES')


n = int(input())
l = list(map(int, input().split()))
x = [0] * 1001
for i in l:
	x[i] += 1
if max(x) <= (n + 1) // 2:
	print('YES')
else:
	print('NO')


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
l = RI()
d = df(int)
for i in l:
	d[i] += 1
f = 0
m = (n + 1) // 2
for i in d:
	if d[i] > m:
		f = 1
		break
if f == 0:
	print('YES')
else:
	print('NO')


from collections import Counter

def calculate(n, numbers):
	counter = Counter(numbers)
	for num in counter:
		if counter[num] > (n + 1) / 2:
			return 'NO'
	return 'YES'
n = int(input())
numbers = list(map(lambda x: int(x), input().split()))
response = calculate(n, numbers)
print(response)


n = int(input())
p = [int(x) for x in input().split()]
s = 0
for i in set(p):
	if p.count(i) >= s:
		s = p.count(i)
if n % 2 == 0:
	if s <= n // 2:
		print('YES')
	else:
		print('NO')
elif s <= n // 2 + 1:
	print('YES')
else:
	print('NO')


m = 0
a = [0] * 1001
n = int(input())
for i in map(int, input().split()):
	a[i] += 1
	if a[i] > m:
		m = a[i]
if m > n // 2 + (1 if n % 2 == 1 else 0):
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
for i in l:
	m = l.count(i)
	if m * 2 > n + 1:
		print('NO')
		exit()
print('YES')


n = int(input())
b = dict()
for x in list(map(int, input().split())):
	if x not in b.keys():
		b[x] = 1
	else:
		b[x] += 1
if any((b[x] > (n + 1) / 2 for x in b.keys())):
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
mx = 0
for i in a:
	mx = max(mx, a.count(i))
if n % 2 == 1:
	if mx > n // 2 + 1:
		print('NO')
	else:
		print('YES')
elif mx > n // 2:
	print('NO')
else:
	print('YES')


from collections import Counter as cn
n = int(input())
a = list(map(int, input().split()))
l = cn(a)
vv = list(l.values())
mx = max(vv)
if n - mx >= mx - 1:
	print('YES')
else:
	print('NO')


import math
x = int(input())
y = list(map(int, input().split(' ')))
m = 0
for i in list(set(y)):
	m = max(m, y.count(i))
if m > math.ceil(x / 2):
	print('NO')
else:
	print('YES')


n = int(input())
a = input().strip().split(' ')
a = [int(ai) for ai in a]
count = dict.fromkeys(set(a), 0)
for ai in a:
	count[ai] += 1
mcount = max(count.values())
if len(count) == 1:
	if n == 1:
		print('YES')
	else:
		print('NO')
elif mcount - 1 > n - mcount:
	print('NO')
else:
	print('YES')


import math
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
a = 0
for i in l:
	a = max(a, d[i])
b = math.ceil(n / 2)
if a <= b or n == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
c = [0] * 1001
for x in a:
	c[x] += 1
if max(c) <= (n + 1) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
P = [0] * 1000
for i in range(n):
	P[A[i] - 1] += 1
ans = 0
for i in range(1000):
	if P[i] > (n + 1) / 2:
		ans = 1
if ans:
	print('NO')
else:
	print('YES')


import math
n = int(input())
a = sorted(list(map(int, input().split())))
ans = []
count = 1
for i in range(0, len(a) - 1):
	if a[i] == a[i + 1]:
		count += 1
	else:
		ans.append(count)
		count = 1
ans.append(count)
if n == 1:
	print('YES')
elif max(ans) > math.ceil(n / 2):
	print('NO')
else:
	print('YES')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def check(l):
	prev = l[0]
	for i in range(1, len(l)):
		if l[i] == prev:
			return 0
		prev = l[i]
	return 1

def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = Counter(a)
	k = (n + 1) // 2
	ans = 1
	for item in d.keys():
		if d[item] <= k:
			pass
		else:
			ans = 0
			break
	if ans:
		print('YES')
	else:
		print('NO')

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


n = int(input())
arr = [int(i) for i in input().split()]
done = False
count = {}
m = 0
for i in arr:
	if i not in count:
		count[i] = 1
		m = max(m, count[i])
	else:
		count[i] += 1
		m = max(m, count[i])
if m > n // 2 + n % 2:
	print('NO')
else:
	print('YES')


import math
import collections
n = int(input())
A = [int(x) for x in input().split()]
D = collections.Counter(A)
m = math.ceil(n / 2)
for v in D.values():
	if v > m:
		print('NO')
		exit()
print('YES')


n = int(input())
li = list(map(int, input().split(' ')))
ma = max(li)
lis = [0 for x in range(ma + 1)]
z = -1
for i in range(0, n):
	lis[li[i]] += 1
	if lis[li[i]] > (n + 1) / 2:
		z = 0
		break
if z == -1:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	nums = list(map(int, input().split(' ')))
	m = {}
	for num in nums:
		if num in m:
			m[num] += 1
		else:
			m[num] = 1
	for num in nums:
		if m[num] > (n + 1) // 2:
			return False
	return True
print('YES') if main() else print('NO')


def inp():
	ls = list(map(int, input().split()))
	return ls
t = int(input())
ls = inp()
ans = [0] * len(set(ls))
all = list(set(ls))
for i in range(len(set(ls))):
	for j in range(t):
		if all[i] == ls[j]:
			ans[i] += 1
for i in ans:
	if i > (t + 1) // 2:
		print('NO')
		exit(0)
print('YES')


n = int(input())
l = [int(i) for i in input().split()]
l1 = [0] * 1000
for i in range(n):
	l1[l[i] - 1] += 1
j = max(l1)
s = 0
c = 0
for i in range(1000):
	if l1[i] == j and c == 0:
		k = i
		c = 1
		continue
	else:
		s += l1[i]
if l1[k] >= s + 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = [int(i) for i in input().split()]
e = set()
d = []
for i in range(n):
	if s[i] not in e:
		d.append(s.count(s[i]))
		e.add(s[i])
if max(d) > -(-n // 2):
	print('NO')
else:
	print('YES')


n = int(input())
l = [x for x in input().split()]
print('YES' if all([l.count(i) * 2 - 1 <= n for i in l]) else 'NO')


3
n = int(input())
a = list(map(int, input().split()))
m = max((len([1 for w in a if w == v]) for v in a))
if 2 * m <= n + 1:
	print('YES')
else:
	print('NO')


n = int(input())
lst = [int(i) for i in input().split()]
d = dict()
for i in lst:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
if n % 2 == 0:
	for i in d:
		if d[i] >= n // 2 + 1:
			print('NO')
			break
	else:
		print('YES')
else:
	for i in d:
		if d[i] >= n // 2 + 2:
			print('NO')
			break
	else:
		print('YES')


n = input()
n = int(n)
aa = {}
x = False
for a in map(int, input().split()):
	try:
		aa[a] = aa[a] + 1
	except:
		aa[a] = 1
for (i, j) in aa.items():
	if n % 2 == 0:
		if j > n / 2:
			x = True
			break
		x = False
	else:
		if j > (n + 1) / 2:
			x = True
			break
		x = False
if x == True:
	print('NO')
else:
	print('YES')


n = int(input())
x = [int(i) for i in input().split()]
Y = 'YES'
for i in x:
	if x.count(i) * 2 > n + 1:
		Y = 'NO'
print(Y)


n = int(input())
l = [int(x) for x in input().split()]
s = set(l)
m = float('-inf')
for i in s:
	m = max(m, l.count(i))
if n >= m + (m - 1):
	print('YES')
else:
	print('NO')


from math import ceil
from collections import Counter
n = int(input())
a = map(int, input().split())
mostCommonCount = Counter(a).most_common(1)[0][1]
print('YES' if mostCommonCount <= ceil(n / 2) else 'NO')


n = int(input())
vals = list(map(int, input().split()))
counts = [0] * 1000
last = -1
cnt_last = -1
for i in range(n):
	counts[vals[i] - 1] += 1
	if cnt_last < counts[vals[i] - 1]:
		last = vals[i]
		cnt_last = counts[vals[i] - 1]
counts[last - 1] -= 1
for i in range(n):
	ma_idx = ma = -1
	for j in range(1000):
		if counts[j] > ma and counts[j] > 0 and (j + 1 != last):
			ma = counts[j]
			ma_idx = j + 1
	if ma != -1:
		counts[ma_idx - 1] -= 1
		last = ma_idx
	else:
		break
if sum(counts) == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
b = set(a)
for i in b:
	cb = 0
	for j in a:
		if j == i:
			cb += 1
	if n % 2 == 1 and cb > n / 2 + 1 or (n % 2 == 0 and cb > n / 2):
		print('NO')
		exit(0)
print('YES')


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
lst = []
i = 0
j = n - 1
turn = 0
while i <= j:
	if turn % 2 == 0:
		lst.append(arr[i])
		i += 1
	else:
		lst.append(arr[j])
		j -= 1
	turn += 1
lst = [-1] + lst
count = cnt = 0
for i in range(-1, -n - 1, -1):
	if lst[i] != lst[i - 1]:
		break
	else:
		count += 1
if count:
	cnt = 0
	num = lst[-1]
	for i in range(1, n + 1):
		if num != lst[i]:
			cnt += 1
		else:
			break
	if count <= cnt:
		print('YES')
	else:
		print('NO')
else:
	print('YES')


from collections import defaultdict
from math import ceil
n = int(input())
array = list(map(int, input().split()))
HashTable = defaultdict(int)
for i in array:
	HashTable[i] += 1
maxVal = max(HashTable.values())
if ceil(n / 2) >= maxVal:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().strip().split(' ')))
ans = [0 for i in range(1005)]
for i in arr:
	ans[i] += 1
p = max(ans)
if n % 2 == 0:
	if p > n // 2:
		print('NO')
	else:
		print('YES')
elif p > n // 2 + 1:
	print('NO')
else:
	print('YES')


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
n = int(input())
nums = list(map(int, input().split()))
nums = sorted(nums, key=lambda x: nums.count(x))
if n % 2 == 0:
	if nums.count(nums[-1]) > n // 2:
		print('NO')
	else:
		print('YES')
elif nums.count(nums[-1]) > n // 2 + 1:
	print('NO')
else:
	print('YES')


n = int(input())
arr = [int(x) for x in input().split()]
max_freq = 0
freq = {}
for ele in arr:
	if ele not in freq:
		freq[ele] = 0
	freq[ele] += 1
	max_freq = max(max_freq, freq[ele])
if max_freq > int((n + 1) / 2):
	print('NO')
else:
	print('YES')


n = int(input())
s = list(map(int, input().split()))
k = max(s, key=s.count)
print('YES' if s.count(k) <= (n + 1) // 2 else 'NO')


from math import ceil
n = int(input())
t = list(map(int, input().split()))
if n == 1:
	print('YES')
else:
	c = max([t.count(x) for x in t])
	if c <= ceil(n / 2):
		print('YES')
	else:
		print('NO')


n = int(input())
numbers = map(int, input().split())
two_count = 0
ans_dict = dict()
for i in numbers:
	ans_dict[i] = ans_dict.get(i, 0) + 1
for (k, v) in ans_dict.items():
	if v > (n + 1) / 2:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
for q in a:
	if a.count(q) > (n + 1) // 2:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
else:
	L = {}
	for item in a:
		if item in L:
			L[item] += 1
		else:
			L[item] = 1
	lim = n // 2
	if n % 2 == 1:
		lim += 1
	ans = 'YES'
	for item in L:
		if L[item] > lim:
			ans = 'NO'
	print(ans)


n = int(input())
line = str(input()).split()
note = dict()
for it in line:
	if it in note.keys():
		note[it] += 1
	else:
		note.setdefault(it, 1)
ceil = max(note.values())
if ceil * 2 > n + 1:
	print('NO')
else:
	print('YES')


import sys
input = sys.stdin.readline
n = int(input())
lst = list(map(int, input().split()))
lst = sorted(lst)
dupl = 1
maxx = 1
for i in range(1, n):
	if lst[i] == lst[i - 1]:
		dupl += 1
		maxx = max(maxx, dupl)
	else:
		dupl = 1
if n == 1:
	print('YES')
elif maxx > n - n // 2:
	print('NO')
else:
	print('YES')


n = int(input())
d = {}
for el in map(int, input().split()):
	d[el] = d.get(el, 0) + 1
x = max(d.values())
if x > (n + 1) // 2:
	print('NO')
else:
	print('YES')


def INT():
	return int(input())

def lis():
	return [int(x) for x in input().split()]
n = INT()
check = (n + 2 - 1) // 2
a = lis()
b = set(a)
flag = 0
for i in b:
	if a.count(i) > check:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(map(int, input().split()))
z = list()
if n == 1:
	print('YES')
	exit()
if n == 2:
	if s[0] == s[1]:
		print('NO')
		exit()
	else:
		print('YES')
		exit()
for i in range(n):
	if s[i] in s[0:i]:
		continue
	z.append(s.count(s[i]))
if len(z) == 1:
	print('NO')
	exit()
if max(z) <= sum(z) - max(z) + 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
b = []
for i in set(a):
	b.append(a.count(i))
k = max(b)
b.remove(max(b))
if k - 1 > sum(b):
	print('NO')
else:
	print('YES')


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
flag = 0
for (key, value) in d.items():
	if value > (n + 1) // 2:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


import math as ma
n = int(input())
arr = [int(i) for i in input().split()]
dic = {}
if len(arr) == 1:
	print('YES')
else:
	for i in range(n):
		if arr[i] not in dic:
			dic[arr[i]] = 1
		else:
			dic[arr[i]] += 1
	m = 0
	for i in dic:
		if dic[i] > m:
			m = dic[i]
	if n - m >= m - 1:
		print('YES')
	else:
		print('NO')


n = int(input())
a = list(map(int, input().split()))
mx = 0
for x in a:
	mx = max(mx, a.count(x))
if mx <= n // 2 + n % 2:
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
cnt = 1010 * [0]
for i in A:
	cnt[i] += 1
for i in range(1010):
	if cnt[i] > (n + 1) // 2:
		print('NO')
		exit(0)
print('YES')


from collections import Counter
from math import ceil
a = int(input())
l = [int(x) for x in input().split()]
f = Counter(l)
can = True
for (k, v) in f.items():
	if v > ceil(a / 2):
		print('NO')
		can = False
if can:
	print('YES')


n = int(input())
a = list(map(int, input().split(' ')))
b = []
c = []
b.extend(a)
a = set(a)
a = list(a)
if n == 1:
	print('YES')
else:
	for i in range(len(a)):
		c1 = 0
		for j in range(len(b)):
			if a[i] == b[j]:
				c1 += 1
		c.append(c1)
	c.sort()
	c.reverse()
	if len(c) == 1:
		print('NO')
	else:
		e = c[0]
		c.pop(0)
		g = e - 1
		if sum(c) >= g:
			print('YES')
		else:
			print('NO')


from collections import Counter
n = int(input())
seats = Counter((int(i) for i in input().split()))
x = (n + 1) // 2
for i in seats.values():
	if i > x:
		print('NO')
		break
else:
	print('YES')


n = int(input())
array = list(map(int, input().split()))
cnt = {i: array.count(i) for i in list(set(array))}
sorted_array = sorted(list(cnt.items()), key=lambda x: x[1])
m = sorted_array.pop()
pp = 0
for i in sorted_array:
	pp += i[1]
if pp >= m[1] - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
x_n = a.count(max(set(a), key=a.count))
if n // 2 + n % 2 >= x_n:
	print('YES')
else:
	print('NO')


import statistics
import sys
arr_size = int(input())
arr = list(map(int, input().split()))
try:
	res = statistics.mode(arr)
except statistics.StatisticsError:
	print('YES')
	sys.exit(0)
freq = 0
for x in arr:
	if x == res:
		freq += 1
if arr_size % 2 == 0:
	max_allowed_num = int(arr_size / 2)
else:
	max_allowed_num = int(arr_size / 2) + 1
if freq <= max_allowed_num:
	print('YES')
else:
	print('NO')


from collections import deque
from heapq import *
n = int(input())
xs = map(int, input().split(' '))
MAXSIZEOMGWTFOFFBYONE = 1100
counts = [0] * MAXSIZEOMGWTFOFFBYONE
for x in xs:
	counts[x] += 1
avail = []
for x in range(MAXSIZEOMGWTFOFFBYONE):
	c = counts[x]
	if c > 0:
		heappush(avail, (-c, x))
last = None
while len(avail) > 0:
	cur = heappop(avail)
	(c, x) = cur
	if x == last:
		if len(avail) == 0:
			print('NO')
			exit()
		(c, x) = heappop(avail)
		heappush(avail, cur)
	c += 1
	last = x
	if c < 0:
		heappush(avail, (c, x))
print('YES')


n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(a.count(a[i]))
print('YES') if max(c) <= (n + 1) / 2 else print('NO')


n = int(input())
arr = list(map(int, input().split()))
fr = {}
for i in arr:
	if i in fr:
		fr[i] += 1
	else:
		fr[i] = 1
maxF = max(fr.values())
if maxF <= (n + 1) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
track = {}
for i in arr:
	if not i in track.keys():
		track[i] = 0
	track[i] += 1
counts = []
for i in track.keys():
	counts.append(track[i])
counts.sort()
counts.reverse()
if len(counts) == 1:
	if len(arr) == 1:
		print('YES')
	else:
		print('NO')
else:
	poss = sum(counts[1:len(counts)]) >= counts[0] - 1
	if poss:
		print('YES')
	else:
		print('NO')


n = int(input())
l = list(map(int, input().split()))
s = list(set(l))
f = len(s)
c = 0
for i in range(f):
	if l.count(s[i]) > (n + 1) // 2:
		c = 1
		break
if c == 1:
	print('NO')
else:
	print('YES')


def obtain_array(n, array):
	for num in set(array):
		counter = array.count(num)
		if counter * 2 - 1 > n:
			return 'NO'
	return 'YES'
n = int(input())
nums = list(map(int, input().split()))
print(obtain_array(n, nums))


from collections import defaultdict
n = int(input())
m = defaultdict(lambda : 0)
t = 0
for i in input().split():
	i = int(i)
	m[i] += 1
	t = max(t, m[i])
if t > (n + 1) / 2:
	print('NO')
else:
	print('YES')


n = int(input())
arr = [int(i) for i in input().split()]
c = 0
for i in arr:
	if c < arr.count(i):
		c = arr.count(i)
if n % 2 == 0 and c >= n // 2 + 1 or (n % 2 == 1 and c >= n // 2 + 2):
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
d = {}
for x in l:
	d[x] = d.get(x, 0) + 1
for x in d:
	if d[x] > (n + 1) // 2:
		print('NO')
		break
else:
	print('YES')


n = int(input())
l1 = list(map(int, input().split()))
for i in l1:
	if l1.count(i) > (n + 1) // 2:
		print('NO')
		break
else:
	print('YES')


from collections import Counter
from math import ceil

def solve(arr, n):
	d = Counter(arr)
	if max(d.values()) > ceil(n / 2):
		print('NO')
	else:
		print('YES')
n = int(input())
arr = list(map(int, input().split()))
solve(arr, n)


n = int(input())
v = list(map(int, input().split()))
sol = 'YES'
for x in v:
	if v.count(x) * 2 > n + 1:
		sol = 'NO'
print(sol)


n = int(input())
a = [int(x) for x in input().split()]
ls = []
stat = 'YES'
for i in a:
	if not a.count(i) <= (n + 1) / 2:
		stat = 'NO'
		break
print(stat)


from math import factorial
n = int(input())
arr = [int(x) for x in input().split(' ')]
map_n = {}
for num in arr:
	if num in map_n:
		map_n[num] += 1
	else:
		map_n[num] = 1
for num in map_n:
	if map_n[num] >= n / 2 + 1:
		print('NO')
		exit(0)
print('YES')


from collections import Counter
n = int(input())
arr = Counter(list(map(int, input().split())))
if n == 1:
	print('YES')
	quit()
elif n == 2:
	if len(arr) > 1:
		print('YES')
	else:
		print('NO')
	quit()
elif n == 3:
	if len(arr) > 1:
		print('YES')
	else:
		print('NO')
	quit()
k = (n + 1) // 2
for i in arr:
	if arr[i] > k:
		print('NO')
		quit()
else:
	print('YES')


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
k = Counter(l)
if n % 2 == 0:
	if k.most_common(1)[0][1] <= n / 2:
		print('YES')
	else:
		print('NO')
elif n % 2 == 1:
	if k.most_common(1)[0][1] <= n // 2 + 1:
		print('YES')
	else:
		print('NO')


n = int(input())
num = map(int, input().split())
from collections import Counter
freq = Counter(num)
maximum = 0
for i in freq:
	if maximum < freq[i]:
		maximum = freq[i]
if maximum <= (n + 1) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
bool = True
for i in range(n):
	x = 0
	for j in range(n):
		if a[i] == a[j]:
			x += 1
	if n < 2 * x - 1:
		bool = False
		break
if bool:
	print('YES')
else:
	print('NO')


import collections
n = int(input())
a = [int(i) for i in input().split()]
d = collections.Counter(a)
flag = 0
if n % 2 == 0:
	s = n // 2
else:
	s = (n + 1) // 2
for i in a:
	if d[i] > s:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == len(l):
	print('YES')
else:
	t1 = {}
	for i in range(n):
		if l[i] in t1:
			t1[l[i]] += 1
		else:
			t1[l[i]] = 1
	tch = list(t1.values())
	if max(tch) < n / 2 + 1:
		print('YES')
	else:
		print('NO')


import collections
de = collections.deque([])
n = int(input())
de = [int(x) for x in input().split()]
a = [val for val in set(de)]
b = []
total = 0
for i in a:
	b.append(de.count(i))
	total += de.count(i)
if total - max(b) >= max(b) - 1:
	print('YES')
else:
	print('NO')


n = int(input())
lst = list(map(int, input().split()))
item_appear = {}
for i in lst:
	if i not in item_appear:
		item_appear[i] = 1
	else:
		item_appear[i] += 1
max_appear = max(item_appear.values())
if n - max_appear >= max_appear - 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(i) for i in input().split()]

def test(l) -> bool:
	if n % 2 == 0:
		for e in l:
			if l.count(e) > n / 2:
				return False
		return True
	else:
		for e in l:
			if l.count(e) > (n + 1) / 2:
				return False
		return True
print('YES' if test(l) else 'NO')


import math
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
c = Counter(l)
t = 0
for i in l:
	if c[i] > math.ceil(n / 2):
		print('NO')
		t = 1
		quit()
if t == 0:
	print('YES')


import math
a = math.ceil(int(input()) / 2)
b = list(map(int, input().split()))
c = set(b)
if len(b) >= 2:
	if any((b.count(i) > a for i in c)):
		print('NO')
	else:
		print('YES')
else:
	print('YES')


a = int(input())
b = list(map(int, input().split()))
g = {}
x = []
for i in b:
	if i in g:
		g[i] += 1
	else:
		g[i] = 1
for i in g.values():
	x.append(i)
x = sorted(x, reverse=True)
if a == 1:
	print('YES')
elif len(x) == 1:
	print('NO')
else:
	t = x.pop(0)
	if t - sum(x) <= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
a = set()
d = dict()
v = list(map(int, input().split()))
(mx, sum) = (0, 0)
for i in range(n):
	if v[i] not in a:
		a.add(v[i])
		d[v[i]] = 1
	else:
		d[v[i]] += 1
for x in a:
	if d[x] > mx:
		sum += mx
		mx = d[x]
	else:
		sum += d[x]
if sum + 1 >= mx:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
b = list(set(a))
c = []
for i in range(len(b)):
	c.append(a.count(b[i]))
if n % 2 == 0:
	p = n // 2
else:
	p = n // 2 + 1
if max(c) <= p:
	print('YES')
else:
	print('NO')


n = int(input())
a = [0] * 1001
if n == 1:
	print('YES')
elif n == 2:
	(l, r) = map(int, input().split())
	if l == r:
		print('NO')
	else:
		print('YES')
else:
	l = list(map(int, input().split()))
	for c in l:
		a[c] += 1
		if len(l) % 2 == 1 and a[c] > n // 2 + 1 or (len(l) % 2 == 0 and a[c] > n // 2):
			print('NO')
			exit()
	print('YES')


n = int(input())
l = list(map(int, input().split()))
result = True
if n % 2 == 1:
	for i in range(n):
		if l.count(l[i]) > n // 2 + 1:
			result = False
			break
else:
	for i in range(n):
		if l.count(l[i]) > n // 2:
			result = False
			break
if result:
	print('YES')
else:
	print('NO')


(n, a) = (int(input()), map(int, input().split()))
h = n // 2 + 1 + n % 2
m = {}
for x in a:
	if x in m:
		m[x] += 1
	else:
		m[x] = 1
print('YES' if max(m.values()) < h else 'NO')


n = int(input())
x = list(map(int, input().split()))
freq = {}
for item in x:
	if item in freq:
		freq[item] += 1
	else:
		freq[item] = 1
p = max(freq.values())
q = sum(freq.values()) - p
if q >= p or p - q == 1:
	print('YES')
else:
	print('NO')


from collections import Counter
n = int(input())
line = list(map(int, input().split()))
if len(line) == 1:
	print('YES')
else:
	count_dict = Counter(line)
	seg_val = []
	seg_tmp = []
	seg_len = 0
	n_seg = 0
	max_count = max(count_dict.values())
	max_key = []
	accum = 0
	for (k, v) in count_dict.items():
		if v != max_count:
			accum += count_dict[k]
		else:
			max_key.append(k)
	max_key = set(max_key)
	for i in range(n):
		if i == 0 or line[i] == line[i - 1]:
			seg_tmp.append(line[i])
		if len(seg_tmp) > 1 and (line[i] != line[i - 1] or i == n - 1):
			seg_len = max(seg_len, len(seg_tmp))
			n_seg += 1
			seg_val.append(seg_tmp[0])
			seg_tmp = []
	seg_val = set(seg_val)
	max_len = n // 2 if n % 2 == 0 else n // 2 + 1
	if seg_len > max_len or (accum < max_count - 1 and len(max_key) < 2):
		print('NO')
	else:
		print('YES')


n = int(input())
a = [0] * 1005
mx = 0

def inc(num):
	global mx
	global a
	num = int(num)
	a[num] += 1
	mx = max(mx, a[num])
	return num
b = list(map(inc, input().split()))
print('YES' if mx <= n // 2 + n % 2 else 'NO')


x = int(input())
l = list(input().split(' '))
e = [0] * 1001
for i in l:
	e[int(i)] += 1
for i in e:
	if i > (x + 1) / 2:
		print('NO')
		exit()
print('YES')


from sys import stdin
import math
from collections import defaultdict as dd
n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().split()))
d = dd(int)
for i in l:
	d[i] += 1
a = 0
for i in d.keys():
	if d[i] > math.ceil(n / 2):
		a = 1
print('YES' if a == 0 else 'NO')


n = int(input())
nums = list(map(int, input().split()))
print('YES' if all([nums.count(i) * 2 - 1 <= n for i in nums]) else 'NO')


n = int(input())
l = list(map(int, input().split()))
d = dict()
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
N = (n + 1) // 2
for i in d:
	if d[i] > N:
		print('NO')
		break
else:
	print('YES')


from collections import Counter
from math import ceil
n = int(input())
arr = input().strip().split()
tc = len(arr)
cnt = Counter(arr)
for key in cnt:
	if cnt[key] > ceil(tc / 2):
		print('NO')
		exit()
print('YES')


n = int(input())
l1 = list(map(int, input().split()))
a1 = [0] * 1000
for item in l1:
	a1[item - 1] += 1
if max(a1) > (n + 1) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
a = [int(a) for a in input().split()]
d = dict()
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ma = max(d.values())
if ma <= (n + 1) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
inp = list(map(int, input().split()))
from collections import Counter
c = Counter(inp)
d = list(c.values())
d.sort()
a = 0
for i in range(len(d) - 1):
	d[i + 1] = d[i + 1] - d[i]
	if i != len(d) - 2:
		a += 2 * d[i]
if d[len(d) - 1] > 1 + a:
	print('NO')
else:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	d.setdefault(i, [0])[0] += 1
if len(arr) % 2 == 0:
	cond = len(arr) // 2 + 1
else:
	cond = len(arr) // 2 + 2
for i in d:
	if d[i][0] >= cond:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
occs = {}
for elem in a:
	if elem not in occs:
		occs[elem] = 1
	else:
		occs[elem] += 1
print('YES' if max(occs.values()) <= (n + 1) // 2 else 'NO')


n = int(input())
values = [int(j) for j in input().split()]
cases = [0] * 1100
for i in values:
	cases[i] += 1
if max(cases) <= (n + 1) / 2:
	print('YES')
else:
	print('NO')


from math import ceil
from collections import Counter

def check_distinct(ls):
	if len(ls) == 1:
		return 'YES'
	elif len(ls) == 2 and ls[0] != ls[1]:
		return 'YES'
	elif len(ls) == 2 and ls[0] == ls[1]:
		return 'NO'
	else:
		ans = 'YES'
		for i in range(len(ls) - 1):
			if ls[i] == ls[i + 1]:
				ans = 'NO'
				break
		return ans

def check_dis(ls, counted):
	if len(ls) == 1:
		return 'YES'
	else:
		ans = 'YES'
		for key in counted:
			if counted[key] > ceil(len(ls) / 2):
				ans = 'NO'
				break
		return ans

def io():
	n = int(input())
	ls = list(map(int, input().split()))
	return [n, ls]

def solve():
	(n, ls) = io()
	counted = Counter(ls)
	ans = []
	print(check_dis(ls, counted))
solve()


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
arr = Counter(arr)
b = []
for i in arr:
	b.append(arr[i])
b.sort(reverse=True)
for i in range(1, len(b)):
	b[0] -= b[i]
if b[0] < 2:
	print('YES')
else:
	print('NO')


import math
n = int(input())
D = {}
lt = list(input().split())
for i in lt:
	if i in D:
		D[i] += 1
	else:
		D[i] = 1
if n % 2 == 0:
	if max(D.values()) <= n / 2:
		print('YES')
	else:
		print('NO')
elif max(D.values()) <= math.ceil(n / 2):
	print('YES')
else:
	print('NO')


n = int(input())
lst = [int(i) for i in input().split()]
need = n // 2
if n % 2 != 0:
	need += 1
max_cnt = 0
for el in set(lst):
	max_cnt = max(lst.count(el), max_cnt)
if max_cnt > need:
	print('NO')
else:
	print('YES')


n = int(input())
nums = list(map(int, input().split()))
unique = set(nums)
for num in unique:
	if nums.count(num) > (n + 1) / 2:
		print('NO')
		exit()
print('YES')


n = int(input())
arr = list(map(int, input().split()))
max_ = max(arr, key=arr.count)
print('YES' if arr.count(max_) <= (n + 1) // 2 else 'NO')


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
a = LI()
d = Counter(a)
b = (n + 1) // 2
flag = 1
for i in d.keys():
	if d[i] > b:
		print('NO')
		flag = 0
		break
if flag:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
	if i not in d:
		d.update({i: 1})
	else:
		d.update({i: d[i] + 1})
maxi = 0
for i in d:
	if d[i] > maxi:
		maxi = d[i]
if len(l) - maxi >= maxi - 1:
	print('YES')
else:
	print('NO')


n = int(input())
C = [0] * 1001
for x in input().split():
	C[int(x)] += 1
for x in C:
	if x > (n + 1) / 2:
		print('NO')
		exit(0)
print('YES')


from collections import Counter
n = int(input())
stuff = Counter(input().split())
space = (n - 1) // 2
print('YNEOS'[stuff.most_common()[0][1] - 1 > space::2])


arg = int(input())
l1 = list(map(int, input().strip().split()))
res = -1
for i in l1:
	res = max(res, l1.count(i))
if res <= arg - arg // 2:
	print('YES')
else:
	print('NO')


from math import *

def main():
	p = input()
	s = list(map(int, input().split()))
	maxi = -inf
	z = set(s)
	for i in z:
		maxi = max(s.count(i), maxi)
	print('YES' if maxi <= ceil(len(s) / 2) else 'NO')
main()


n = int(input())
x = list(map(int, input().split()))
d = {}
ma = 1
su = 0
vv = x[0]
for i in range(len(x)):
	try:
		d[x[i]] += 1
		if d[x[i]] > ma:
			ma = d[x[i]]
			vv = x[i]
	except:
		d[x[i]] = 1
for i in d:
	if i != vv:
		su += d[i]
if su >= ma - 1:
	print('YES')
else:
	print('NO')


from collections import Counter
n = int(input())
x = list(map(int, input().split()))
c = Counter(x)
if 2 * max(c.values()) > n + 1:
	print('NO')
else:
	print('YES')


def input_ints():
	return list(map(int, input().split()))

def output_list(v):
	print(' '.join((str(x) for x in v)))

def main():
	n = int(input())
	a = input_ints()
	for x in a:
		if 2 * a.count(x) > n + 1:
			print('NO')
			return
	print('YES')
main()


n = int(input())
a = map(int, input().split())
cnt = dict()
for b in a:
	if b not in cnt:
		cnt[b] = 0
	cnt[b] += 1
for v in cnt.values():
	if v > (n + 1) // 2:
		print('NO')
		exit(0)
print('YES')


n = int(input())
x = [int(i) for i in input().split()]
ans = 'YES'
for i in x:
	if x.count(i) > n + 1 - x.count(i):
		ans = 'NO'
print(ans)


from collections import Counter

def solve():
	n = int(input())
	arr = input().split()
	freqs = Counter(arr)
	max_val_key = max(freqs, key=freqs.get)
	max_val = freqs[max_val_key]
	del freqs[max_val_key]
	if sum(freqs.values()) >= max_val - 1:
		print('YES')
	else:
		print('NO')
solve()


n = int(input())
arr = list(map(int, input().split()))
if n == 1:
	print('YES')
else:
	occur = []
	s1 = set(arr)
	flag = True
	if len(s1) == 1:
		print('NO')
	else:
		for i in s1:
			occur.append(arr.count(i))
			if occur[-1] > (n + 1) / 2:
				flag = False
		if flag:
			print('YES')
		else:
			print('NO')


import math
nums = eval(input())
list = input().split()
max1 = 0
for i in list:
	if max1 < list.count(i):
		max1 = list.count(i)
if max1 > math.ceil(len(list) / 2):
	print('NO')
else:
	print('YES')


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = iinput()
h = (n + 1) / 2
a = list(map(int, input().split()))
l = list(set(a))
s = len(l)
r = []
for i in range(s):
	r.append(a.count(l[i]))
m = max(r)
if m <= h:
	print('YES')
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def main():
	n = I()
	a = LI()
	c = collections.Counter(a)
	if n == 1 or max(c.values()) <= (n + 1) // 2:
		return 'YES'
	return 'NO'
print(main())


n = int(input())
l = input().split()
my_dict = {i: l.count(i) for i in l}
m = max(my_dict.values())
thres = n // 2
if n % 2 == 1:
	thres += 1
if m > thres:
	print('NO')
else:
	print('YES')


import sys
import math
input = sys.stdin.readline
cnts = [0] * 1500
n = int(input().strip())
a = list(map(int, input().strip().split()))
for el in a:
	cnts[el] += 1
if n - max(cnts) >= max(cnts) - 1:
	print('YES')
else:
	print('NO')


n = int(input())
if n == 1:
	print('YES')
	exit()
nums = [int(i) for i in input().split()]
max = 0
D = {}
for num in nums:
	if num not in D:
		D[num] = 0
	D[num] += 1
	if D[num] > max:
		max = D[num]
mid = (n + 1) // 2
if max > mid:
	print('NO')
else:
	print('YES')


n = int(input())
a = [int(x) for x in input().split()]
d = dict()
max = 0
for e in a:
	if not e in d:
		d[e] = 0
	d[e] += 1
	if d[e] > max:
		max = d[e]
if max > (n + 1) // 2:
	print('NO')
else:
	print('YES')


def f(l):
	n = len(l)
	cl = [0] * 1001
	for i in l:
		cl[i] += 1
	return max(cl) <= (n + 1) // 2
q = int(input())
l = list(map(int, input().split()))
print('YES' if f(l) else 'NO')


n = int(input())
l = list(map(int, input().split()))
if n % 2 == 0:
	k = 0
else:
	k = -1
for i in range(n):
	if l.count(l[i]) + k > n // 2:
		print('NO')
		exit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
b = {}
for i in a:
	if i in b:
		b[i] += 1
	else:
		b[i] = 1
t = 0
for i in b:
	if b[i] > t:
		t = b[i]
if n - t >= t - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
ans = 'YES'
for (k, v) in d.items():
	if n % 2 == 0:
		if d[k] > n // 2:
			ans = 'NO'
	elif d[k] > (n + 1) // 2:
		ans = 'NO'
print(ans)


n = int(input())
l = list(map(int, input().split(' ')))
dic = dict()
for item in l:
	if item in dic:
		dic[item] += 1
	else:
		dic[item] = 1
maximum = max(dic.values())
if maximum <= (n + 1) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = [0] * 1001
f = True
t = list(map(int, input().split()))
for i in range(n):
	a = t[i]
	s[a] += 1
for i in range(1001):
	if s[i] > (n + 1) // 2:
		f = False
if f:
	print('YES')
else:
	print('NO')


n = int(input())
lst1 = input().split()
dict1 = {}
for i in lst1:
	if i in dict1:
		dict1[i] += 1
	else:
		dict1[i] = 1
l = len(lst1)
Max = max(dict1.values())
if Max > (l + 1) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
mx = 0
for i in arr:
	mx = max(mx, arr.count(i))
print('YES' if mx <= n // 2 + n % 2 else 'NO')


n = int(input())
a = list(map(int, input().split()))
ok = True
for val in a:
	if a.count(val) > (n + 1) // 2:
		ok = False
		break
print('YES' if ok else 'NO')


import math

def find_max(f):
	m = -1
	for i in range(1, 1001):
		m = max(m, f[i])
	return m
n = int(input())
arr = list(map(int, input().split()))
f = [0] * (1000 + 1)
for i in range(n):
	f[arr[i]] += 1
m = find_max(f)
if math.ceil(n / 2) >= m:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
mx_rep = 0
memorize = []

def get_ocurrences(no):
	ocurr = 0
	for i in arr:
		if no == i:
			ocurr += 1
	if ocurr == 1:
		return 0
	else:
		return ocurr
for i in range(0, n):
	rep = 0
	if arr[i] not in memorize:
		rep += get_ocurrences(arr[i])
	memorize.append(arr[i])
	mx_rep = max(rep, mx_rep)
if 2 * mx_rep - 1 <= n:
	print('YES')
else:
	print('NO')


def yaroslav():
	n = int(input())
	a = list(map(int, input().split()))
	cunts = [0 for i in range(1001)]
	for i in range(n):
		cunts[a[i]] = a.count(a[i])
	maxcount = 0
	for i in range(1001):
		if cunts[i] > cunts[maxcount]:
			maxcount = i
	if n % 2 == 0:
		if a.count(maxcount) > n // 2:
			print('NO')
			return
	elif a.count(maxcount) > n // 2 + 1:
		print('NO')
		return
	print('YES')
yaroslav()


import math
N = int(input())
numbers = list(map(int, input().split()))
if all((e == numbers[0] for e in numbers)) and N != 1:
	print('NO')
elif N == 1:
	print('YES')
else:
	set_of_numbers = list(set(numbers))
	counter = [None] * len(set_of_numbers)
	for i in range(len(set_of_numbers)):
		counter[i] = numbers.count(set_of_numbers[i])
	if max(counter) > math.ceil(N / 2):
		print('NO')
	else:
		print('YES')


x = [0]
m = x * 1001
z = int(input())
for z in map(int, input().split()):
	m[z] += 1
s = max(m)
m[m.index(s)] = 0
h = 0
e = 0
while h < len(m):
	e += m[h]
	h += 1
if e >= s - 1:
	print('YES')
else:
	print('NO')


n = int(input())
b = list(map(int, input().split()))
b = sorted(b)
if n % 2 == 0:
	g = n / 2
else:
	g = n / 2 + 1
f = True
c = 1
for i in range(1, n):
	if b[i] == b[i - 1]:
		c += 1
	else:
		c = 1
	if c > g:
		f = False
if f or n == 1:
	print('YES')
else:
	print('NO')


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def case():
	n = int(input())
	a = li()
	c = Counter(a)
	m = 0
	for i in c:
		m = max(m, c[i])
	if m > n // 2 + n % 2:
		print('NO')
	else:
		print('YES')
for _ in range(1):
	case()


import sys
n = int(sys.stdin.readline())
ais = list(map(int, sys.stdin.readline().split()))
print('YES' if all((ais.count(i) * 2 - 1 <= n for i in ais)) else 'NO')


n = int(input())
a = input().split()
b = set(a)
d = {}
S = len(a)
for i in b:
	d[i] = a.count(i)
for (i, k) in d.items():
	if S - k < k - 1:
		print('NO')
		exit()
print('YES')