#include #include #include #include #include using namespace std; typedef long long LL; const int N = 1e3 + 7; int n, a[N]; int work(int T = 0) { memset(a, 0, sizeof(a)); scanf("%d", &n); for(int i = 0, x; i < n; i ++) scanf("%d", &x), a[x]++; LL cnt = 0, tmp = 0; for(int i = 300; i > 0; i --) cnt += a[i] * (n-tmp-a[i]), tmp += a[i]; printf("%.6f\n", 1.0*cnt/(n*(n-1))); return 0; } int main() { int T = 0; scanf("%d", &T); for(int i = 1; i <= T; i ++) work(i); return 0; }