FFT computed convolution
#include <bits/stdc++.h> using namespace std;
const INT maxn=1<<18;
Const long Long mod=998244353;
const int g=3;
Long Long REV[MAXN],W[2][MAXN];
Long Long FAC[MAXN],INV[MAXN];
Long Long A[MAXN];
Long Long powmod (long long X,long long p) {Long long ret=1;
while (p) {if (p&1) Ret=ret*x%mod;
X=x*x%mod;
p>>=1;
} return ret;
} void Init () {fac[0]=1;
for (int i=1;i<maxn;i++) Fac[i]=fac[i-1]*i%mod;
Inv[maxn-1]=powmod (fac[maxn-1],mod-2);
for (int i=maxn-2;i>=0;i--) inv[i]=inv[i+1]* (i+1)%mod;
} void Initfft (int n) {int i,k,x,y,v,dv;
for (i=0;i<=n-1;i++) {x=i;
y=0;
For (K=1;k<n;k<<=1,x>>=1) (y<<=1) |= (x&1);
Rev[i]=y;
} v=powmod (G, (mod-1)/n);
Dv=powmod (v,mod-2);
W[0][0]=w[1][0]=1;
for (i=1;i<=n-1;i++) {w[0][i]=w[0][i-1]*v%mod;
W[1][i]=w[1][i-1]*dv%mod;
}} The inline void FFT (long long *a,int n,int ff) {int i,j,k,t,l,v,x,y; for (i=0;i<=n-1;i++) {if (I<rev[i]) swap (a[i],a[rev[i]);
} for (I=1;i<n;i<<=1) {for (j=0,t=n/(i<<1), j<n;j+= (i<<1)) {for (k=0,l=0;k<i;k++,l+=t)
{x=a[i+j+k]*w[ff][l]%mod;
Y=A[J+K];
a[j+k]= (x+y)%mod;
a[i+j+k]= (y+mod-x)%mod;
}}} if (ff) {v=powmod (n,mod-2);
for (i=0;i<=n-1;i++) A[i]=a[i]*v%mod;
}} int NUM[MAXN];
int main () {int t,n,i,m,mx,x;
Long Long sum,tmp;
Double ans;
scanf ("%d", &t);
while (t--) {scanf ("%d", &n);
memset (num,0,sizeof (num));
mx=0;
for (i=0;i<n;i++) {scanf ("%d", &x);
num[x]++;
Mx=max (MX,X);
} m=1;
while (m<=2*mx+2) m<<=1;
Initfft (m);
for (i=0;i<m;i++) a[i]=num[i];
FFT (a,m,0);
for (i=0;i<m;i++) A[i]=a[i]*a[i]%mod;
FFT (a,m,1); for (i=0;i<m;i++) {if (!) (
i&1)) a[i]-=num[i>>1];
a[i]>>=1;
} tmp=0;
sum=0;
for (i=1;i<m;i++) {tmp+=a[i];
Sum+=tmp*num[i];
} ans=1.0-sum*6.0/n/(n-1)/(n-2);
printf ("%.7f\n", ans); }
}