#include #include #include #include #include #include #include #include #include #include #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; const int MN=300+10; const int ME=100000+10; const int MOD=2520; typedef long long LL; typedef unsigned long long ULL; const double pi=acos(-1.0); const int Intmax=(~(1<<31)); const int Intmin=(1<<31); const LL LLmax=(~(1LL<<63)); const LL LLmin=(1LL<<63); const ULL ULLmax=(~(0ULL)); typedef long long LL; int a[MN]; int main(){ #ifndef ONLINE_JUDGE freopen("1.cpp","r",stdin); #endif // ONLINE_JUDGE int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); memset(a,0,sizeof(a)); int m=n; while(m--){ int x; scanf("%d",&x); a[x]++; } int sum=0; int ans=0,i; for(i=300;i>=1;i--){ if(a[i]){ sum+=a[i]; ans+=(n-sum)*a[i]; } } double res=ans*1.0/(n*(n-1)); printf("%.6f\n",res); } return 0; }