Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

Solution:
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const long double pi = 3.1415926535897932384L;
long double f(double x) {
	if (x + 1 <= 1.0e-9L) return pi;
	if (x - 1 >= -1.0e-9L) return 0.0L;
	return acos(x);
}
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	long double ret = 0.0;
	for (int i = 1; i < 1 << n; i++) {
		vector<int> sub;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) sub.push_back(v[j]);
		}
		sort(sub.begin(), sub.end());
		int m = sub.size();
		if (m <= 2) continue;
		do {
			function<long double(long double) > calc = [&](long double x) {
				long double ret = 0.0;
				for (int k = 0; k < m; k++) ret += f(x / (sub[k] * sub[(k + 1) % m]));
				return ret;
			};
			long double l = -1.0e+7, r = 1.0e+7;
			for (int j = 0; j < 60; j++) {
				long double mid = (l + r) * 0.5L;
				if (calc(mid) > 2 * pi) l = mid;
				else r = mid;
			}
			long double res = 0.0, sum = 0.0;
			for (int j = 0; j < m; j++) {
				long double ang = f(l / (sub[j] * sub[(j + 1) % m])); sum += ang;
				res += sub[j] * sub[(j + 1) % m] * sin(ang);
			}
			ret = max(ret, res);
		} while (next_permutation(sub.begin(), sub.end()));
	}
	cout << fixed << setprecision(15) << ret * 0.5 << endl;
	return 0;
}