#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int T, n;
cin >> T;
while(T) {
cin >> n;
int a[n];
cin >> a[0];
float sum = a[0];
int min = a[0], max = a[0];
for(int i = 1; i < n; i++) {
cin >> a[i];
sum += a[i];
if (min > a[i]) {
min = a[i];
}
if (max < a[i]) {
max = a[i];
}
}
cout << max - min <<" ";
double fc = 0.0;//使用double,防止溢出
for(int i = 0; i < n; i++) {
fc += ((double)(a[i] - (sum / n)) * (double)(a[i] - (sum / n)));
}
printf("%.3f\n", fc/n);
//cout << fc / n << endl;
T--;
}
}
// 64 位输出请用 printf("%lld")