#include #include using namespace std; int a[400]; int main() { int T,n,i,j,tot; double ans; scanf("%d",&T); while (T--) { scanf("%d",&n); tot=0; for (i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); for (i=1;i<=n;) { for (j=i;a[i]==a[j] && j<=n;j++) ; tot+=(j-i)*(i-1); i=j; } ans=(double)tot/(n*(n-1)); printf("%.6lf\n",ans); } }