Language: C++

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & -(x))
#define BIT(a,b) ((ll)((a)&(1 << (b)))==0 ? false : true)

const ll MAXN=1e5+10;

ll a[MAXN];

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    ll n,u=1000000,t=0,x=0;
    cin >> n;

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

        u=min(u , a[i]);
    }

    for(ll i=0;i<n;i++)
    {
        if (a[i]!=u)
        {
            goto E;
        }
    }

    if (u==(n-1) || 2*u<=n)
    {
        cout << "Yes";
        return 0;
    }
    else
    {
        cout << "No";
        return 0;
    }

    E:;

    for(ll i=0;i<n;i++)
    {
        if (a[i]>u+1)
        {
            cout << "No";
            return 0;
        }

        if (a[i]==u)
        {
            t++;
        }
        else
        {
            x++;
        }
    }

    if (x==1)
    {
        cout << "No";
        return 0;
    }

    if (t<=u && (x/2)+t>=(u+1))
    {
        cout << "Yes";
        return 0;
    }
//eweveve
    else
    {
        cout << "No";
        return 0;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'ios_base' has not been declared
   25 |     ios_base :: sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:26:5: error: 'cin' was not declared in this scope
   26 |     cin.tie(0);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:35:11: error: 'min' was not declared in this scope; did you mean 'main'?
   35 |         u=min(u , a[i]);
      |           ^~~
      |           main
a.cc:48:9: error: 'cout' was not declared in this scope
   48 |         cout << "Yes";
      |         ^~~~
a.cc:48:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:53:9: error: 'cout' was not declared in this scope
   53 |         cout << "No";
      |         ^~~~
a.cc:53:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:63:13: error: 'cout' was not declared in this scope
   63 |             cout << "No";
      |             ^~~~
a.cc:63:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:79:9: error: 'cout' was not declared in this scope
   79 |         cout << "No";
      |         ^~~~
a.cc:79:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:85:9: error: 'cout' was not declared in this scope
   85 |         cout << "Yes";
      |         ^~~~
a.cc:85:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:91:9: error: 'cout' was not declared in this scope
   91 |         cout << "No";
      |         ^~~~
a.cc:91:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'