#include #include #include #include #include #include using namespace std; int num[350]; int ans[350]; int sum; int main () { int T; cin>>T; while(T--) { int n; cin>>n; for(int i = 0; i < n; i++) cin>>num[i]; sort(num,num+n); sum = 0; ans[0] = 0; int tt = 0; for(int i = 1; i < n; i++) { if(num[i] == num[i-1]) { ans[i] = ans[i-1]; tt++; } else { ans[i] = ans[i-1]+1+tt; tt = 0; } sum+=ans[i]; } printf("%.6f\n", (double)sum/(n*(n-1))); } return 0; }