Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}
int bsr(int x) { return 31 - __builtin_clz(x); }

using R = long double;
const R PI = acos(R(-1));

R solve(vector<R> v) {
    int n = (int)v.size();
    v.push_back(v[0]);
    R l = 0, r = PI, area;
    for (int fe = 0; fe < 50; fe++) {
        R md = (l+r)/2;
        R sm = md, th = md;
        area = v[0]*v[1]*sin(th);
        for (int i = 1; i < n; i++) {
            R x = cos(th)*v[i-1]/v[i+1];
            if (1 < x) {
                sm = 0;
                break;
            }
            if (x < -1) {
                sm = 3*PI;
                break;
            }
            th = acos(x);
            sm += th;
            area += v[i]*v[i+1]*sin(th);
        }
        if (sm < 2*PI) {
            l = md;
        } else {
            r = md;
        }
        if (abs(sm-2*PI) <= 1e-9) {
            return area/2;
        }
    }
    return 0;
}

int main() {
    int n;
    cin >> n;
    vector<R> r(n);
    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }
    R ans = 0;
    sort(begin(r), end(r));
    for (int i = 0; i < (1<<n); i++) {
        if (__builtin_popcount(i) < 3) continue;
        vector<R> v;
        for (int j = 0; j < n; j++) {
            if (i & (1<<j)) {
                v.push_back(r[j]);
            }
        }
        sort(v.begin(), v.end());
        do {
            ans = max(ans, solve(v));
        } while (next_permutation(v.begin()+1, v.end()));
    }
    printf("%.20Lf\n", ans);
    return 0;
}