Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ll n, sum = 0;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		a[i] = min(a[i], 5);
	}
	sort(a.begin(), a.end());
	vector<ll> u, v;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			u.push_back(i);
			v.push_back(j);
		}
	}
	int N = n * (n - 1) / 2;
	ll ma = 0;
	for (int i = 0; i < (1 << N); i++) {
		vector<ll> b(n);
		ll cnt = 0;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				b[u[j]]++;
				b[v[j]]++;
				cnt++;
			}
		}
		bool can = true;
		for (int j = 0; j < n; j++) {
			if (b[j] > a[j]) {
				can = false;
				break;
			}
		}
		if (can) {
			ma = max(ma, cnt);
		}
	}
	if (n == 5 && a[0] >= 3 && a[1] >= 3 && a[2] >= 3 && a[3] >= 5 && a[4] >= 5) {
		ma = max(ma, 9);
	}
	cout << sum - ma << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)'
   13 |                 a[i] = min(a[i], 5);
      |                        ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:13:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   13 |                 a[i] = min(a[i], 5);
      |                        ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:13:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |                 a[i] = min(a[i], 5);
      |                        ~~~^~~~~~~~~
a.cc:47:25: error: no matching function for call to 'max(ll&, int)'
   47 |                 ma = max(ma, 9);
      |                      ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:47:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |                 ma = max(ma, 9);
      |                      ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:47:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |                 ma = max(ma, 9);
      |                      ~~~^~~~~~~