Highway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into n sub-tracks. You are given an array a where a_i represents the number of traffic cars in the i-th sub-track. You define the inconvenience of the track as ∑_{i=1}^{n} ∑_{j=i+1}^{n} \lvert a_i-a_j\rvert, where |x| is the absolute value of x. 

You can perform the following operation any (possibly zero) number of times: choose a traffic car and move it from its current sub-track to any other sub-track.

Find the minimum inconvenience you can achieve.

Input

The first line of input contains a single integer t (1≤ t≤ 10 000) — the number of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 2⋅ 10^5).

The second line of each test case contains n integers a_1, a_2, …, a_n (0≤ a_i≤ 10^9).

It is guaranteed that the sum of n over all test cases does not exceed 2⋅ 10^5.

Output

For each test case, print a single line containing a single integer: the minimum inconvenience you can achieve by applying the given operation any (possibly zero) number of times.

Example

Input


3
3
1 2 3
4
0 1 1 0
10
8 3 6 11 5 2 1 7 10 4


Output


0
4
21

Note

For the first test case, you can move a car from the 3-rd sub-track to the 1-st sub-track to obtain 0 inconvenience.

For the second test case, moving any car won't decrease the inconvenience of the track.

import java.lang.*;
import java.math.*;
import java.io.*;
import java.util.*;

 
public class Practice{
	
	
	 static class FastReader {
	        BufferedReader br;
	        StringTokenizer st;
	 
	        public FastReader()
	        {
	            br = new BufferedReader(
	                new InputStreamReader(System.in));
	        }
	 
	        String next()
	        {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine());
	                }
	                catch (IOException e) {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }
	 
	        int nextInt() { return Integer.parseInt(next()); }
	 
	        long nextLong() { return Long.parseLong(next()); }
	 
	        double nextDouble()
	        {
	            return Double.parseDouble(next());
	        }
	 
	        String nextLine()
	        {
	            String str = "";
	            try {
	                str = br.readLine();
	            }
	            catch (IOException e) {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }
	 
	 
	 static long  gcd(long a, long b) {


	    if (b == 0) {
	        return a;}
	    else {
	        return gcd(b, a % b);}}
	 
	 //for prime no
	  static boolean isPrime(int n) {
	        return BigInteger.valueOf(n).isProbablePrime(1);
	    }
	 
	    static boolean isPrime(long n) {
	        return BigInteger.valueOf(n).isProbablePrime(1);
	    }

	 static boolean[] seiveOfEratoSthenes(int n) {
		 boolean isPrime[]=new boolean[n+1];
		 Arrays.fill(isPrime, true);
		 isPrime[0]=false;
		 isPrime[1]=false;
		 for(int i=2;i<=Math.sqrt(n);i++) {
			 for(int j=2*i;j<=n;j+=i) {
				 isPrime[j]=false;
			 }
		 }
		 
		 return isPrime;
		 
	 }
	 
	 static long modulo(long a,long b,int n) {
		 long res=1;
		 
		 while(b>0) {
			 if((b&1)==1) {
				 res=(res*(a%n))%n;
			 }
			 a=((a%n)*(a%n))%n;
			 b=b>>1;
			 
		 }
		 return res;
	 }
	 
	 static class Pair  implements Comparable<Pair>{
		 int a;
		 int b;
		 
		
	
		 
		 Pair(int tim,int index){  
			 this.b=index;
			  
			 this.a=tim;  
		
			 }  
		 public int compareTo(Pair st){  
			 if(a==st.a)  
			 return b-st.b;  
			 else if(a>st.a)  
			 return 1;  
			 else  
			 return -1;  
			 }  
	 } 
	 
	
	 static boolean isPalindrome(String s) {
	        int length = s.length();
	        for (int i = 0; i < length / 2; i++) {
	            if (s.charAt(i) != s.charAt(length - 1 - i)) {
	                return false;
	            }
	        }
	        return true;
	    }
	 
	 	static void reverseArray(int[] arr) {
	        for (int i = 0; i < arr.length / 2; i++) {
	            int temp = arr[i];
	            arr[i] = arr[arr.length - 1 - i];
	            arr[arr.length - 1 - i] = temp;
	        }
	    }
	 
	    static void reverseArray(String[] arr) {
	        for (int i = 0; i < arr.length / 2; i++) {
	            String temp = arr[i];
	            arr[i] = arr[arr.length - 1 - i];
	            arr[arr.length - 1 - i] = temp;
	        }
	    }
	 
	    static void reverseArray(char[] arr) {
	        for (int i = 0; i < arr.length / 2; i++) {
	            char temp = arr[i];
	            arr[i] = arr[arr.length - 1 - i];
	            arr[arr.length - 1 - i] = temp;
	        }
	    }

	    
	    static long LCM( long a, long b)
	    {
	    	long g = gcd(a, b);
	    	a /= g;
	    	return a*b;
	    }
	    public static void main(String[] args)
	    {
	        FastReader sc = new FastReader();
//	        System.out.println();	
	    
	        
	        
	        
	        int t=sc.nextInt();
	        while(t-->0) {
	        	int n=sc.nextInt();
	        	long arr[]=new long[n];
	        	
	        	long sum=0;
	        	for(int i=0;i<n;i++) {
	        		arr[i]=sc.nextLong();
	        		sum+=arr[i];
	        	}
		    	
	        	
	        	long avg=sum/n;
	        	
	        	long num=(sum-(avg*n));
	        	
	        	long ans=num*(n-num);
	        	
	        	System.out.println(ans);
		    	
	        	
	        }
	     
	    }
	    
	 
	    
	    static long number(int n, int digit) {
	    	
	    	long var=0;
	    	
	    	for(int i=0;i<digit;i++) {
	    		var+=n;
	    		var*=10;
	    	}
	    	var/=10;
	    	return var;
	    	
	    } 
	        
	 	
	    static int binary(int start,int end,int arr[],int v ) {
	 		int Q=0;
	 	    if (end <= start) 
	 	        { Q=(v >= arr[start])?  start : (start-1); }
	 	    else{
	 	  
	 	    int mid = (start + end)/2; 
	 	  
	 	    if(v == arr[mid]) 
	 	       return mid; 
	 	  
	 	    if(v >arr[mid]) {
	 	        Q= binary( mid+1, end,arr, v); }
	 	    else if(v <arr[mid]){
	 	    Q= binary( start, mid-1,arr, v); }}
	 	    return Q;
	 	}
	        	 
 




       
       
   
    
     static boolean isCycle(boolean vis[], ArrayList<ArrayList<Integer>> adj,int v,int parent)
    {
        vis[v]=true;
        
        
        for(int i:adj.get(v)){
            if(vis[i]&&parent!=i){
                return true;
            }
            else if(vis[i]){
                continue;
            }
            boolean a= isCycle(vis,adj,i,v);
            if(a)return true;
            
            
        }
        return false;
        
    }
}    
	     
	 
	
	
 class pair{
    int a;
    int b;
    pair(int p,int q){
        a=p;
        b=q;
    }
    public boolean equals(Object o) {
        if (o instanceof pair) {
            pair p = (pair)o;
            return p.a == a && p.b == b;
        }
        return false;
    }
    public int hashCode() {
        return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
    }
}   

     
	  