number = int(input())
numbers = list(map(int, input().split()))
from collections import defaultdict
count = defaultdict(int)
for num in numbers:
if num in count.keys():
count[num] += 1
else:
count[num] = 1
for value in count.values():
if number % 2 == 0 and value > int(number / 2):
print('NO')
exit()
elif number % 2 == 1 and value > int(number / 2) + 1:
print('NO')
exit()
print('YES')
// I Love Adiya? I don't know, maybe only Allah knows. Nevertheless I will believe in the good situations.
// I will fuck everyone, I am sure that I will improve everything which I have bad.
//
// main.cpp
// solve pb
//
// Created by Apple on 19.05.2021.
//
// I hate girl whose name is *****, cause of her i suffer to be better than yesterday
// When i see her, her face motivates me to win competitions and be closer to her
// recently I've seen one girl who doesn't motivate me, I'd say she pulls me down
// my future goal is to be winner and I'll fuck everyone who will stand before me
/*
WRITTEN BY I_love_Tanya_Romanova
https://codeforces.com/profile/I_love_Tanya_Romanova
Blind and ambiguous, all part of the game
I've feigned my ambivalence with a smile
All my hate beneath me forms a cage
All this time to form the man I became
The sun in my hand becomes my despair
For I still want the truth
Play the fool so ignorant in the shadow of disdain
Breeding your deception without eyes
All my hate beneath me forms a cage
All this time to form the man I became
The sun in my hand becomes my despair
For I still want the truth
Play the fool so ignorant, deception is the game
Bleeding hearts and soiled minds
Reflect the state of our being
All my hate beneath me forms a cage
All this time to form the man I became
The sun in my hand becomes my despair
The sun in my hand becomes my despair
Play the fool so ignorant, deception is the game
Bleeding hearts and soiled minds
Reflect the state of our being
//
// 09.10.cpp
// 09102022.cpp
//
// Created by Apple on 09.10.2022.
//
*/
#include <algorithm>
#include <bitset>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <memory>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <valarray>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;
#define pb push_back
#define bp pop_back
#define bk back
#define em emplace_back
#define ft first
#define sd second
#define mp make_pair
#define vc vector
#define sz size
#define SZ(a) a.size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sorta(a) sort(a + 1, a + 1 + n)
#define reversea(a) reverse(a + 1, a + 1 + n)
#define Vi vector<int>
#define N 100010
#define SUMMOD 1073741824 //2^30
#define PI 3.141592653589793 //3.14
#define MOD 998244353
#define CIN(n) scanf("%d", &n)
#define Cin(n) cin >> n
#define CINA(a) scanf("%d", a+i)
#define lcin(n) ll n; cin >> n;
#define icin(n) int n; cin >> n;
#define cinnm(n, m) int n, m; cin >> n >> m;
#define Str(s) string s; cin >> s;
#define CheckNo(n,a) if (n == a) {cout << "NO\n"; return;}
#define CheckYes(n,a) if (n == a) {cout << "YES\n"; return;}
#define For(i,a,n) for(int (i) = (a); (i) < (n); (i)++)
#define For1(i,a,n) for(int (i) = (a); (i) <= (n); (i)++)
#define forauto(u,n) for (auto &(u) : (n))
#define For2(i,n,a) for(int (i) = (n); (i) >= (a); (i)--)
#define iosbase ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define print(n) printf("%d\n", n);
#define printChar(n) printf("%s\n", n);
#define MODMX 4294967296
#define Jzzhu 1000000007
#define ForArray(a, n) int a[1000000]; for(int i=0;i<(n);i++){cin>>a[i];}
#define ForArraySum(a, n, sum) int a[1000000]; double sum = 0; for(int i=0;i<(n);i++){cin>>a[i];sum+=a[i];}
#define FixSet(n) cout << fixed << setprecision(n);
#define cl clear
typedef long long ll;
typedef long double ld;
//using ll = long long;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
//typedef vector<Vi> vvi;
const int INF = 1e9+7, MaxN = 2*1e6+123, Nn = 410+123, Mx = 1501, MM = 203, lol = 2*1e5, MAXN = 1e5;
//const int Inf = ((1 << 31) - 1);
const int mod = (int) 1e15 + 37;
void file() {
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
}
ll a[MaxN];
ll b[MaxN];
//ll c[MaxN];
ll *c=a+Mx+Nn+MM;
ll sa, sb;
// char ar[Mx][Mx];
string str;
ll arr[Mx][Mx];
// vc<ll> ans;
//vc<pll> a, b;
//gipotinuza
ll gipo(ll r, ll x, ll y, ll x1, ll y1) {
//int r, x, y, x1, y1;
//scanf("%d%d%d%d%d", &r, &x, &y, &x1, &y1);
printf("%d\n", (int) ceil(hypot(x - x1, y - y1) / r / 2));
}
//sifr
ll sifr(ll n) {
ll cnt = 0;
while (n) {
ll chislo = n % 10;
if (chislo == 4 or chislo == 7) {
cnt++;
} n /= 10;
} return cnt;
}
bool is_prime(int n) {
if(n == 2) return true;
else if(n % 2 == 0) return false;
else {
int n_n = sqrt((double)n);
for (int i = 3; i <= n_n; i+=2) {
if (n % i == 0) return false;
}
} return true;
}
ll cntx, cnty, sx, sy, ex, ey;
char direction;
ll absdir(ll x, ll y) {
return abs(x - ex) + abs(y - ey);
}
void checkandplus(ll x, ll y, char direc) {
cntx = x, cnty = y;
if (direc == 'N') {
cnty++;
} if (direc == 'E') {
cntx++;
} if (direc == 'S') {
cnty--;
} if (direc == 'W') {
cntx--;
}
}
ll dp[MaxN];
ll sum[MaxN];
ll check;
void a_ans() {
lcin(n);
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[a[i]]++;
if (sum[a[i]] * 2 > n + 1) {
check = 1;
}
} CheckNo(check, 1);
CheckYes(check, 0);
}
int main(int argc, const char * argv[]) {
//file();
iosbase;
int tt = 1;
//cin >> tt;
while (tt--) {
a_ans();
}
/*
7
1 3
2 4
-2 -100
1 5
8 9
-3 -101
2 3
*/
return 0;
}
/*
3,1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
*/
1635B - Avoid Local Maximums | 20A - BerOS file system |
1637A - Sorting Parts | 509A - Maximum in Table |
1647C - Madoka and Childish Pranks | 689B - Mike and Shortcuts |
379B - New Year Present | 1498A - GCD Sum |
1277C - As Simple as One and Two | 1301A - Three Strings |
460A - Vasya and Socks | 1624C - Division by Two and Permutation |
1288A - Deadline | 1617A - Forbidden Subsequence |
914A - Perfect Squares | 873D - Merge Sort |
1251A - Broken Keyboard | 463B - Caisa and Pylons |
584A - Olesya and Rodion | 799A - Carrot Cakes |
1569B - Chess Tournament | 1047B - Cover Points |
1381B - Unmerge | 1256A - Payment Without Change |
908B - New Year and Buggy Bot | 979A - Pizza Pizza Pizza |
731A - Night at the Museum | 742A - Arpa’s hard exam and Mehrdad’s naive cheat |
1492A - Three swimmers | 1360E - Polygon |