Problem: Example

Input

4
5
8
58
85


Output

2970.000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define EPS 1e-6
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a[11];
int len[11];
int len2[11];
int ord[11];
double ans=0.0;

double C(int n,double deg){
	double sum=deg;
	for(int i=1;i<n;i++){
		double cosi=(double)(len2[0]*len2[1])/(len2[i]*len2[(i+1)%n])*cos(deg);
		if(cosi>1.0){
			return 0.0;
		}
		if(cosi<-1.0){
			return 720;
		}
		sum+=acos(cosi);
	}
	return sum;
}

double calc(int n,double deg){
	double sum=0;
	for(int i=0;i<n;i++){
		double cosi=(double)(len2[0]*len2[1])/(len2[i]*len2[(i+1)%n])*cos(deg);
		//printf("%.5f ",cosi);
		double degi=acos(cosi);
		//printf("%.5f ",degi*180.0/M_PI);
		sum+=len2[i]*len2[(i+1)%n]*sin(degi);
	}
	//printf("\n");
	return sum;
}

double func(int n){
	for(int i=0;i<n;i++){
		len2[i]=len[ord[i]];
	}
	double l=EPS,r=M_PI;
	for(int i=0;i<50;i++){
		double mid=(l+r)/2.0;
		if(C(n,mid)<2*M_PI){
			l=mid;
		}else{
			r=mid;
		}
	}
	return calc(n,l);
}

void solve(int n){
	for(int i=0;i<n;i++){
		len[i]=a[i];
	}
	for(int i=0;i<n;i++){
		ord[i]=i;
	}
	do{
		ans=max(ans,func(n));
	}while(next_permutation(ord+1,ord+n));
}

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=3;i<=n;i++){
		solve(i);
	}
	printf("%.9f\n",ans/2.0);
	return 0;
}