Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-6

int N;
vector<double> r;

int main(){
  cin>>N;
  r.resize(N);
  rep(i,N){
    cin>>r[i];
  }
  sort(all(r));
  double res=0;
  do{
    repl(k,3,N+1){
      double lb=0,ub=PI;
      rep(_,100){
        double X=(lb+ub)/2.0;
        double cos1=cos(X);
        double theta=0;
        bool ok=true;
        rep(i,k){
          double p=((r[0]*r[1])/(r[i]*r[(i+1)%k]))*cos1;
          if(p<-1.0)p=-1.0;
          if(p>+1.0)p=+1.0;
          theta+=acos(((r[0]*r[1])/(r[i]*r[(i+1)%k]))*cos1);
        }
        if(theta<2*PI)lb=X;
        else ub=X;
      }
      double sum=0;
      double cos1=cos(lb);
      double thetasum=0;
      rep(i,k){
        double p=((r[0]*r[1])/(r[i]*r[(i+1)%k]))*cos1;
        if(p<-1.0)p=-1.0;
        if(p>+1.0)p=+1.0;
        sum+=(r[i]*r[(i+1)%k])*sin(acos(p));
        thetasum+=acos(p);
      }
      if(abs(thetasum-2.0*PI)<eps)maxch(res,sum/2.0);
    }
  }while(next_permutation(all(r)));
  printf("%.10f\n",res);
  return 0;
}