Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> r(N);
	for (int i = 0; i < N; i++)
		cin >> r[i];
	sort(r.begin(), r.end());
	double ma = 0;
	for (; N >= 3; N--, r.erase(r.begin())) {
		do {
			double ub = DBL_MAX;
			for (int i = 0; i < N; i++)
				ub = min(ub, (double)r[i] * r[(i + 1) % N]);
			double lb = -ub;
			bool ok = false;
			for (int t = 0; t < 100; t++) {
				double mid = (lb + ub) / 2, sum = 0;
				for (int i = 0; i < N; i++)
					sum += acos(mid / r[i] / r[(i + 1) % N]);
				if (sum <= M_PI*2) {
					ub = mid;
					ok = true;
				}
				else lb = mid;
			}
			if (!ok) continue;
			double S = 0;
			for (int i = 0; i < N; i++)
				S += sqrt(pow(r[i] * r[(i + 1) % N], 2) - lb * lb);
			ma = max(ma, S);
		} while (next_permutation(r.begin(), r.end()));
	}
	printf("%.15f\n", ma / 2);
}