Pages

1/19/2014

UVA 11364 java solution

import java.util.Arrays;
import java.util.Scanner;

public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
boolean flag = true;
int tc = sc.nextInt();
for (int i = 0; i<tc; i++) {
int no = sc.nextInt();
int [] arr = new int [no];
for (int j =0 ; j < no ;j++) arr[j] = sc.nextInt();
Arrays.sort(arr);
System.out.println(2*(arr[no-1] - arr[0]));

}
}

}