stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include<stdio.h>

#include<string.h>

#include<set>

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    set<int>st;

    for(int i=1; i<=n; i++)

    {

        int x;

        cin>>x;

        if(st.count(x))

        {

            st.erase(x);

        }

        else st.insert(x);

    }

    cout<<st.size()<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

int a[100050];

int main()

{

    int n,k=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n; )

    {

        if(a[i]==a[i+1])

            i=i+2;

        else

        {

            k++;

            i++;

        }

    }

    printf("%d\n",k);

    return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,x=1,ans=0;///x表示一个数出现的次数，赋值1

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);///先排序

    for(int i=1;i<n;i++)

    {

        if(a[i]==a[i-1])///出现相同的数，x+1然后mod2

          x=(x+1)%2;

        else

        {

            ans+=x;///单独的一个数，ans+1，x重新赋值为1，进行循环

            x=1;

        }

    }

    if(x%2)///再次判断 ，若不为0，则ans+1

      ans++;

    printf("%d\n",ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

int a[100050];

int main()

{

    int n,k=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n; )

    {

        if(a[i]==a[i+1])

            i=i+2;

        else

        {

            k++;

            i++;

        }

    }

    printf("%d\n",k);

    return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<stack>

using namespace std;

#define ll long long

ll a[100005];

int main()

{

    stack<int>s;

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>a[i];

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(!s.empty())

        {

            if(a[i]==s.top())

            {

                s.pop();

            }

            else

                s.push(a[i]);

        }

        else

        {

           s.push(a[i]);

        }

    }

    int num=s.size();

    cout<<num<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

int a[100050];

int main()

{

    int n,k=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n; )

    {

        if(a[i]==a[i+1])

            i=i+2;

        else

        {

            k++;

            i++;

        }

    }

    printf("%d\n",k);

    return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<string.h>

#include<iostream>

#include<set>

#include<algorithm>

using namespace std;

int main()

{

    std::ios::sync_with_stdio(false);

    int n;

    cin>>n;

    set<int>a;

    int x;

    while(n--)

    {

        cin>>x;

        if(a.count(x))

            a.erase(x);

        else

            a.insert(x);

    }

    printf("%d",a.size());

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

int a[100050];

int main()

{

    int n,k=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n; )

    {

        if(a[i]==a[i+1])

            i=i+2;

        else

        {

            k++;

            i++;

        }

    }

    printf("%d\n",k);

    return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int main(){

	int n,a[100005],ma[100005]={0},j=0,ans=0;

	cin>>n;for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);for(int i=0;i<n;i++){if(a[i]==a[i+1])ma[j]++;else{ma[j]++;j++;}}for(int l=0;l<n;l++)if(ma[l]%2==1)ans++;cout<<ans<<endl;return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<cmath>

#include<algorithm>

//#define MODE 1

#ifdef MODE

#define DEB(X) cout<<#X<<": "<<X<<" ";

#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";

#define END cout<<endl;

#else

#define DEB(X) {}

#define ARDEB(X) {}

#define END {}

#endif

using namespace std;

int main(){

	int n;

	int a[100001],co=0,ans=0;

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	sort(a,a+n);

	for(int i=0;i<n;i++){

		if(a[i]==a[i+1])co++;

		if(a[i]!=a[i+1]){

			co++;

			if(co%2==1)ans++;

			co=0;

		}

	}

	cout<<ans<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



int main(void)

{

	int n;

	cin >> n;

	map<int, bool> m;

	while (n--) {

		int i;

		cin >> i;

		m[i] = !m[i];

	}

	int c = 0;

	for (auto i = m.begin(); i != m.end(); ++i) {

		if (i->second) c++;

	}

	cout << c << endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int N,ptr,res;

int A[100000];

int main()

{

    scanf("%d", &N);

    for (int i=0;i<N;i++)scanf("%d",&A[i]);

    sort(A,A+N);

    while(ptr<N)

    {

        int cc=A[ptr],f=0;

        while(ptr<N&&A[ptr]==cc)f++,ptr++;

        res+=f%2;

    }

    printf("%d\n",res);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int N;

vector<uint32_t> A;

int a;

int c = 0;

int main()

{

    scanf("%d", &N);

    while (N--) {

        scanf("%d", &a);

        A.push_back(a);

    }

    sort(A.begin(), A.end());

    uint32_t i = 1, prev = A[0], count = 1;

    A.push_back(0);

    while (i<A.size()) {

        if (A[i] != prev) {

            if (count % 2 == 1) {

                c++;

            }

            count = 1;

            prev = A[i];

        } else {

            count++;

        }

        i++;

    }

    cout << c << endl;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int N,ptr,res;

int A[100000];

int main()

{

    scanf("%d", &N);

    for (int i=0;i<N;i++)scanf("%d",&A[i]);

    sort(A,A+N);

    while(ptr<N)

    {

        int cc=A[ptr],f=0;

        while(ptr<N&&A[ptr]==cc)f++,ptr++;

        res+=f%2;

    }

    printf("%d\n",res);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <set>

using namespace std;

int N; set<long long> A; long long t;

int main() {

  scanf("%d", &N);

  for(int i = 0, c; i < N; i++) {

    scanf("%lld", &t);

    c = A.count(t);

    if(c < 1) A.insert(t);

    else if(c == 1) A.erase(t);

  }

  printf("%d", A.size());

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int N, ans, A[100001];

int main() {

  scanf("%d", &N);

  for(int i = 0; i < N; i++) scanf("%d", &A[i]);

  sort(A, A+N);

  for(int i = 0, cnt = 0, pre = 0; i <= N; i++) {

    if(pre == A[i]) cnt++;

    else {ans += cnt%2; cnt = 1;}

    pre = A[i];

  }

  printf("%d", ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>



using namespace std;



void count()

{

	int N;



	cin >> N;

	int data[100000];

	fill_n(data, 100000, 0);

	for (int i = 0; i < N; i++)

	{

		cin >> data[i];

	}

	sort(data, data + N);

	int cnt = 0;

	int meyasu = 0;

	int kazoe = 0;

	while (meyasu < N)

	{

		int kazoe = 0;

		int handan = data[meyasu];

		while (meyasu < N && handan == data[meyasu])

		{

			meyasu++;

			kazoe++;

		}

		cnt += kazoe % 2;

	}

	

	cout << cnt << endl;



}





int main()

{

	count();

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <vector>

#include <cmath>

#include <map>

#include <iomanip>

#include <deque>

typedef long long ll;

#define rep(i,a,b) for(int i=a;i<b;++i)

#define rrep(i,a,b) for(int i=a;i>=b;--i)

using namespace std;

using vi = vector<int>;

using vll = vector<ll>;

ll mod = 1e9 + 7;

ll llmax = 10000000000000000000ll;

using namespace std;

using Graph = vector<vector<int>>;

Graph G;

const int AMAX = 100000;

/*int cnt_digit(ll N)

{

	int digit = 0;



	while (N > 0)

	{

		N /= 10;

		digit++;

	}

	return digit;

}







int n;

vll a;



ll solve(bool isp)

{

	ll sum = 0ll;

	ll ret = 0ll;



	for (int i = 0; i < n; i++)

	{

		sum += a[i];

		if (isp and sum <= 0)

		{

			ret += -sum + 1;

			sum = 1ll;

		}

		if (not isp and sum >= 0)

		{

			ret += sum + 1;

			sum = -1ll;

		}

		isp ^= 1;

	}

	return ret;

}



*/





/*

 * 最大公約数計算

 */

ll gcd(ll a, ll b)

{

	if (b == 0) {

		return a;

	}

	else {

		return gcd(b, a % b);

	}

}



ll lcm(ll a, ll b)

{

	ll g = gcd(a, b);



	return a / g * b;

}



int main()

{

	cin.tie(0);

	ios::sync_with_stdio(false);

	

	int N;



	cin >> N;

	int ans = 0;

	vector <int>data(N);

	for (auto &x : data)

	{

		cin >> x;

	}

	/*for (auto &i : data)

	{

		cout << i << endl;

	}*/

	map <int, int>box;

	for (auto &x : data)

	{

		box[x]++;

	}

	

	for (auto &x : box)

	{

		if (x.second % 2 != 0)

		{

			ans++;

		}

	}

	

		cout << ans << endl;

	return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <map>

using namespace std;



const int MN = 200005;



int N;

int A[MN];



map<int,int> B;

typedef map<int,int>::iterator IT;



bool check(int M) {

	B.clear();

//	printf("M = %d :\n", M);

	for (int i = 1; i <= N; ++i) {

		if (A[i - 1] >= A[i]) {

			int j = A[i];

			while (j && ++B[j] == M)

				B[j--] = 0;

			if (!j) return 0;

		}

		else {

			IT it = B.end();

			if (it != B.begin()) {

				--it;

				while (it->first > A[i - 1]) {

					IT tmp = it;

					if (it != B.begin()) --it, B.erase(tmp);

					else {B.erase(tmp); break;}

				}

			}

		}

//		for (int j = 1; j <= A[i]; ++j)

//			printf("%c", B[j] + 'a');

//		puts("");

	}

	return 1;

}



int main() {

	int ok = 1;

	scanf("%d", &N);

	for (int i = 1; i <= N; ++i) {

		scanf("%d", A + i);

		if (A[i - 1] >= A[i])

			ok = 0;

	}

	if (ok) return puts("1"), 0;

	int lb = 2, rb = N, mid, ans = -1;

	while (lb <= rb) {

		mid = lb + rb >> 1;

		if (check(mid)) ans = mid, rb = mid - 1;

		else lb = mid + 1;

	}

	printf("%d\n", ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



const int MN = 200005;



int N, A[MN];



int stkp[MN], stkv[MN], tp;

inline bool check(int M) {

	tp = 0;

	for (int i = 1; i <= N; ++i) {

		if (A[i] <= A[i - 1]) {

			while (stkp[tp] > A[i]) --tp;

			int pos = A[i];

			while (pos) {

				if (stkp[tp] != pos || stkv[tp] != M - 1) {

					if (stkp[tp] != pos)

						stkp[++tp] = pos,

						stkv[tp] = 0;

					++stkv[tp];

					break;

				} else --tp, --pos;

			}

			if (!pos) return 0;

		}

	}

	return 1;

}



int main() {

	int ok = 1;

	scanf("%d", &N);

	for (int i = 1; i <= N; ++i) {

		scanf("%d", &A[i]);

		if (A[i] <= A[i - 1]) ok = 0;

	}

	if (ok) return puts("1"), 0;

	int lb = 2, rb = N, mid = 0, ans = 0;

	while (lb <= rb) {

		mid = (lb + rb) >> 1;

		if (check(mid)) ans = mid, rb = mid - 1;

		else lb = mid + 1;

	}

	printf("%d\n", ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int a[100005],n;

int v[100005];

int main()

{

	while(~scanf("%d",&n))

	{

		bool flag=0;int mi=1e9,ma=0;

		for(int i=1;i<=n;++i)

		{

			scanf("%d",&a[i]);

			mi=min(mi,a[i]);

			ma=max(ma,a[i]);

			v[a[i]]++;

			if(i>1&&a[i]!=a[i-1])flag=1;

		}

		if(ma-mi>1)puts("No");

		else if(!flag)

		{

			if(ma==n-1)puts("Yes");

			else

			{

				if(n/2>=mi)puts("Yes");

				else puts("No");

			}

		}

		else

		{

			if(v[mi]+v[ma]/2>=ma&&ma>v[mi])puts("Yes");

			else puts("No");

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#define MAXN 100005



int n;

int a[MAXN];

int ma,mi=(int)1e9;

int cnt;

int p;



int main(){

	scanf("%d",&n);

	for(int i=1;i<=n;i++){

		scanf("%d",a+i);

		ma=std::max(ma,a[i]);

		mi=std::min(mi,a[i]);

	}

	if(ma-mi>1||ma>n-1){

		p=0;

	}else if(ma==mi){

		if(ma==n-1) p=1;

		else if(ma*2<=n) p=1;

		else p=0; 

	}else{

		for(int i=1;i<=n;i++)

			if(a[i]==mi) cnt++;

		if(2*(ma-cnt)<=n-cnt&&ma>cnt) p=1;

		else p=0;

	}

	printf("%s\n",p?"Yes":"No");

}










// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdlib>

#include<iostream>

#include<cstring>

#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

int n,maxx=-1,minn=1e9;

int a[100010],num[100010];

bool flag=0;

int main()

{

	scanf("%d",&n);

	for(int i=1;i<=n;i++)

	{

		scanf("%d",&a[i]);

		num[a[i]]++;

		maxx=max(maxx,a[i]);

		minn=min(minn,a[i]);

		if(a[i]!=a[i-1]&&i>=2)flag=1;

	}

	if(maxx-minn>1){printf("No");return 0;}

	if(flag)

	{

		if(2*(maxx-num[minn])<=num[maxx]&&maxx>num[minn])printf("Yes");

		else printf("No");

	}

	else

	{

		int x=a[1];

		if(x==1||x==n-1||x==n/2)printf("Yes");

		else printf("No");

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#define MAXN 100005



int n;

int a[MAXN];

int ma,mi=(int)1e9;

int cnt;

int p;



int main(){

	scanf("%d",&n);

	for(int i=1;i<=n;i++){

		scanf("%d",a+i);

		ma=std::max(ma,a[i]);

		mi=std::min(mi,a[i]);

	}

	if(ma-mi>1||ma>n-1){

		p=0;

	}else if(ma==mi){

		if(ma==n-1) p=1;

		else if(ma*2<=n) p=1;

		else p=0; 

	}else{

		for(int i=1;i<=n;i++)

			if(a[i]==mi) cnt++;

		if(2*(ma-cnt)<=n-cnt&&ma>cnt) p=1;

		else p=0;

	}

	printf("%s\n",p?"Yes":"No");

}










// Fastest known solution for this problem:
// Original C++ solution (slower):
//... ...

#include<cstdio>

#include<cstring>

#include<iostream>

using namespace std;

const int M = 1e5 + 7;

int a[M];



int main() {

	int n;

	cin >> n;

	for(int i = 1 ; i <= n ; i++) cin >> a[i];

	int l = a[1] , r = a[1];

	for(int i = 2 ; i <= n ; i++) {

		l = min(a[i] , l);

		r = max(a[i] , r);

	}

	if(r - l > 1) cout << "No" << endl;

	else {

		if(l == r) {

			int gg = n - l;

			if(gg == 1) cout << "Yes" << endl;

			else {

				if(n == 1 || gg >= l) cout << "Yes" << endl;

				else cout << "No" << endl;

			}

		} else {

			int cnt1 = 0 , cnt2 = 0;

			for(int i = 1 ; i <= n ; i++) {

				if(a[i] == l) cnt1++;

				if(a[i] == r) cnt2++;

			}

			if(cnt1 >= r) cout << "No" << endl;

			else {

				int gg = n - r;

				if(gg >= r - cnt1) cout << "Yes" << endl;

				else cout << "No" << endl;

			}

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

inline int in();

inline void wr(int);

const int N=(int)1e5+5;

int a[N];

inline int mx(int,int);

inline int mn(int,int);

int main(int argc,char**argv){

#ifndef ONLINE_JUDGE

//	freopen("2386.in","r",stdin);

//	freopen("2386.ans","w",stdout);

#endif

	register int n=in();

	for(register int i=1;i<=n;++i)

		a[i]=in();

	register int x=0,y=n;

	for(register int i=1;i<=n;++i)

		x=mx(x,a[i]),y=mn(y,a[i]);

	if(x-y>1){puts("No");return 0;}

	if(!(x-y)){puts((x==n-1||(x<<1)<=n)?"Yes":"No");return 0;}

	register int m=0;

	for(register int i=1;i<=n;++i)

		m+=(a[i]==y);

	if(1+m<=x&&x<=m+((n-m)>>1))puts("Yes");

	else puts("No");

}

inline int mx(int x,int y){

	return x>y?x:y;

}

inline int mn(int x,int y){

	return x<y?x:y;

}

inline int in(){

	register char c=getchar();

	register int x=0,f=1;

	for(;c<'0'||c>'9';c=getchar())

		if(c=='-')f=-1;

	for(;c>='0'&&c<='9';c=getchar())

		x=(x<<1)+(x<<3)+(c&15);

	return x*f;

}

inline void wr(int x){

	if(x<0)putchar('-'),x=-x;

	if(x/10)wr(x/10);

	putchar(x%10+'0');

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int a[100010];

int main()

{

	int n,maxx=0,minn=1e9,t=0,sum=0;

	scanf("%d",&n);

	for(int i=1;i<=n;i++)

		scanf("%d",a+i),maxx=max(maxx,a[i]),minn=min(minn,a[i]);

	if(maxx-minn>1)

	{

		puts("No");

		return 0;

	}

	if(maxx==minn&&minn==n-1)

	{

		puts("Yes");

		return 0;

	}

	for(int i=1;i<=n;i++)

		if(a[i]==maxx)t++;

		else sum++;

	if(sum>=maxx)

	{

		puts("No");

		return 0;

	}

	sum=maxx-sum;

	if(sum*2<=t)puts("Yes");

	else puts("No");

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

inline int in();

inline void wr(int);

const int N=(int)1e5+5;

int a[N];

inline int mx(int,int);

inline int mn(int,int);

int main(int argc,char**argv){

#ifndef ONLINE_JUDGE

//	freopen("2386.in","r",stdin);

//	freopen("2386.ans","w",stdout);

#endif

	register int n=in();

	for(register int i=1;i<=n;++i)

		a[i]=in();

	register int x=0,y=n;

	for(register int i=1;i<=n;++i)

		x=mx(x,a[i]),y=mn(y,a[i]);

	if(x-y>1){puts("No");return 0;}

	if(!(x-y)){puts((x==n-1||(x<<1)<=n)?"Yes":"No");return 0;}

	register int m=0;

	for(register int i=1;i<=n;++i)

		m+=(a[i]==y);

	if(1+m<=x&&x<=m+((n-m)>>1))puts("Yes");

	else puts("No");

}

inline int mx(int x,int y){

	return x>y?x:y;

}

inline int mn(int x,int y){

	return x<y?x:y;

}

inline int in(){

	register char c=getchar();

	register int x=0,f=1;

	for(;c<'0'||c>'9';c=getchar())

		if(c=='-')f=-1;

	for(;c>='0'&&c<='9';c=getchar())

		x=(x<<1)+(x<<3)+(c&15);

	return x*f;

}

inline void wr(int x){

	if(x<0)putchar('-'),x=-x;

	if(x/10)wr(x/10);

	putchar(x%10+'0');

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<cstdio>

using namespace std;

#define N 1000005

int n,a[N];

int maxx,minn;

int one,two;//unique 重名？！ 

int main(){

	maxx=0;minn=N;

	one=0;two=0;

	scanf("%d",&n);

	for(int i=1;i<=n;i++){

		scanf("%d",&a[i]);

		maxx=max(maxx,a[i]);

		minn=min(minn,a[i]);

	}

	if(maxx==minn){//correct 

		if(minn==n-1||minn<=n/2){

			printf("Yes\n");

		}else{

			printf("No\n");

		}

	}else if(maxx-minn>1||maxx>=n){

		printf("No\n");

	}else{

		for(int i=1;i<=n;i++){

			if(a[i]==minn) one++;

			else two++;

		}

		if(one>=maxx){//correct

			printf("No\n");

		}else if(one+two/2<maxx){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<bits/locale_facets.h>

#include<algorithm>

using namespace std;

int a[100001];

long long input();

int main()

{

	int n=input(),total=0;

	for(int i=1;i<=n;i++)a[i]=input();

	sort(a+1,a+n+1);

	if(a[n]-a[1]>1||a[n]>=n)printf("No");

	else if(a[n]==a[1])

	{

		if(a[n]*2>n&&a[n]<n-1)printf("No");

		else printf("Yes");

	}

	else

	{

		for(int i=1;i<=n&&a[i]<a[n];i++)total++;

		if(0<a[n]-total&&2*a[n]<=n+total)printf("Yes");

		else printf("No");

	}

	return 0;

}

long long input()

{

	long long value=0,positive=1;

	char digit=getchar();

	for(;!isdigit(digit);digit=getchar())

	if(digit=='-')positive=-positive;

	for(;isdigit(digit);digit=getchar())value=(value<<3)+(value<<1)+digit-'0';

	return positive*value;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define ll long long

#define ull unsigned long long

#define met(a, x) memset(a,x,sizeof(a));

#define inf 0x3f3f3f3f

#define mp make_pair;



using namespace std;

const int mod = 1e9 + 7;

const int N = 1e6 + 10;

const int M = 1e5 + 10;

int a[M + 10];



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int n;

    while (cin >> n) {

        for (int i = 1; i <= n; i++) {

            cin >> a[i];

        }

        sort(a + 1, a + 1 + n);

        if (a[n] - a[1] > 1||a[n]>=n) {

            cout << "No" << endl;

        } else {

            int cnt1 = 0, cnt2 = 0;

            for (int i = 1; i <= n; i++) {

                if (a[i] == a[n]) {

                    cnt2++;

                } else if (a[n] == a[i] + 1){

                    cnt1++;

                }

            }

            int cnt = cnt1 + cnt2 / 2;

            if (cnt1 == 0) {

                if (a[n] == n - 1 || 2*a[n]<=n) {

                    cout << "Yes" << endl;

                } else {

                    cout << "No" << endl;

                }

            } else {

                if (cnt >= a[n] && cnt2 != 1&&cnt1<a[n])

                    cout << "Yes" << endl;

                else

                    cout << "No" << endl;

            }

        }

    }

    return 0;

}




// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<bits/locale_facets.h>

#include<algorithm>

using namespace std;

int a[100001];

long long input();

int main()

{

	int n=input(),total=0;

	for(int i=1;i<=n;i++)a[i]=input();

	sort(a+1,a+n+1);

	if(a[n]-a[1]>1||a[n]>=n)printf("No");

	else if(a[n]==a[1])

	{

		if(a[n]*2>n&&a[n]<n-1)printf("No");

		else printf("Yes");

	}

	else

	{

		for(int i=1;i<=n&&a[i]<a[n];i++)total++;

		if(0<a[n]-total&&2*a[n]<=n+total)printf("Yes");

		else printf("No");

	}

	return 0;

}

long long input()

{

	long long value=0,positive=1;

	char digit=getchar();

	for(;!isdigit(digit);digit=getchar())

	if(digit=='-')positive=-positive;

	for(;isdigit(digit);digit=getchar())value=(value<<3)+(value<<1)+digit-'0';

	return positive*value;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=50005;

int a[100005],n;

int main()

{

    scanf("%d",&n);

    int mx=0;

    int mn=0x3f3f3f3f;

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

        mx=max(mx,a[i]);

        mn=min(mn,a[i]);

    }

    if(mx-1>mn)

    {

        printf("No\n");

        return 0;

    }

    if(mx==mn)

    {

        if(mn==n-1)

        {

            printf("Yes\n");

            return 0;

        }

        if(2*mn<=n)

        {

            printf("Yes\n");

            return 0;

        }

        else

        {

            printf("No\n");

            return 0;

        }

    }

    else

    {

        int ant=0;

        for(int i=0;i<n;i++)

        {

            if(a[i]==mn)

                ant++;

        }

        if(mn<ant)

        {

            printf("No\n");

            return 0;

        }

        if(n-ant<2*(mx-ant))

        {

            printf("No\n");

            return 0;

        }

        else

        {

            printf("Yes\n");

            return 0;

        }

    }

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<bits/locale_facets.h>

#include<algorithm>

using namespace std;

int a[100001];

long long input();

int main()

{

	int n=input(),total=0;

	for(int i=1;i<=n;i++)a[i]=input();

	sort(a+1,a+n+1);

	if(a[n]-a[1]>1||a[n]>=n)printf("No");

	else if(a[n]==a[1])

	{

		if(a[n]*2>n&&a[n]<n-1)printf("No");

		else printf("Yes");

	}

	else

	{

		for(int i=1;i<=n&&a[i]<a[n];i++)total++;

		if(0<a[n]-total&&2*a[n]<=n+total)printf("Yes");

		else printf("No");

	}

	return 0;

}

long long input()

{

	long long value=0,positive=1;

	char digit=getchar();

	for(;!isdigit(digit);digit=getchar())

	if(digit=='-')positive=-positive;

	for(;isdigit(digit);digit=getchar())value=(value<<3)+(value<<1)+digit-'0';

	return positive*value;

}

// Fastest known solution for this problem: