/*
 * Warmup Contest #2, September 4, 2010 Problem C 
 * Solution by Jonathon Paulson
 * Originally from http://ncpc.idi.ntnu.no/ncpc2007/ncpc2007problems.pdf (problem C) 
 * ACM NCPC 2007 Problem C
 * 
 * The problem reduces to 2*(max - min) where max is the largest position 
 * of a store and min is the smallest. 
 *
 */


import java.util.Arrays;
import java.util.Scanner;

public class C {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n_cases = in.nextInt();
		for(int trial=1; trial<=n_cases; trial++) {
			int n=in.nextInt();
			int max = -1,min=1000;
			for(int i=0; i<n; i++){
				int pt = in.nextInt();
				if(pt > max)
					max = pt;
				if(pt < min)
					min = pt;
			}
			System.out.println(2*(max-min));
		}
	}
}
