Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1234576891234601LL;
ll _MOD = 1000000009;
double EPS = 1e-10;

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);
}