#include<bits/stdc++.h>

using namespace std;

int main()

{

int t,a[10005],i,n,maxm=-9999,minm=9999,s1;
double s=0,ave,s2;
cin>>t; 
while(t--) 
{
    s2=0,maxm=-9999,minm=9999,s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        s=s+a[i];
        maxm=max(maxm,a[i]);
        minm=min(minm,a[i]);
    }
    s1=maxm-minm;
    ave=s*1.0/n;
    for(i=1;i<=n;i++)
    {
        s2+=(a[i]-ave)*(a[i]-ave);
    }
    s2=s2/n;
    printf("%d %.3lf\n",s1,s2);
}
return 0;

}