import java.util.Arrays;
import java.util.Scanner;
//Q. 주차의 신
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int[] result = new int[t];
for (int i=0;i<t;i++){
int distance=0;
int n = sc.nextInt(); // 방문할 상정의 수 n
int[] xi = new int[n]; //상점의 위치 xi
for(int j=0;j<n;j++){
xi[j] = sc.nextInt();
}
Arrays.sort(xi);
for(int j=1;j<n;j++){
distance+=xi[j]-xi[j-1];
}
result[i]=distance*2;
}
for(int i=0;i<t;i++){
System.out.println(result[i]);
}
}
}