Program:
[cpp]
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int main()
{
// freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int T,x,i,sum,m;
scanf("%d",&T);
while (T--)
{
scanf("%d",&n);
sum=n*(n-1)*(n-2)/6;
m=0;
for (i=1;i<=n;i++)
{
scanf("%d",&x);
m+=x*(n-1-x);
}
m/=2;
m=sum-m;
printf("%.3lf\n",m*1.0/sum);
}
return 0;
}