description: There are n block towers in a row, where tower i has a height of a_i. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:
  
    * Choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), and move a block from tower i to tower j. This essentially decreases a_i by 1 and increases a_j by 1. 
  
  
  
  You think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as max(a)-min(a). 
  
  What's the minimum possible ugliness you can achieve, after any number of days?
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.
  
  The first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of buildings.
  
  The second line of each test case contains n space separated integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7) — the heights of the buildings.
  
  Output
  
  For each test case, output a single integer — the minimum possible ugliness of the buildings.
  
  Example
  
  Input
  
  
  3
  3
  10 10 10
  4
  3 2 1 2
  5
  1 2 3 1 5
  
  
  Output
  
  
  0
  0
  1
  
  Note
  
  In the first test case, the ugliness is already 0.
  
  In the second test case, you should do one operation, with i = 1 and j = 3. The new heights will now be [2, 2, 2, 2], with an ugliness of 0.
  
  In the third test case, you may do three operations: 
  
    1. with i = 3 and j = 1. The new array will now be [2, 2, 2, 1, 5], 
    2. with i = 5 and j = 4. The new array will now be [2, 2, 2, 2, 4], 
    3. with i = 5 and j = 3. The new array will now be [2, 2, 3, 2, 3]. 
  
  The resulting ugliness is 1. It can be proven that this is the minimum possible ugliness for this test.
solution: /* JAIKARA SHERAWAALI DA BOLO SACHE DARBAR KI JAI
  HAR HAR MAHADEV JAI BHOLENAATH
  Rohit Kumar 
  NIT JAMSHEDPUR
  
  
          "Everything in the universe is balanced. Every disappointment
                  you face in life will be balanced by something good for you!
                          Keep going, never give up."
   
  */
   
   
  
  import java.util.*;
  
  import java.io.*;
  
  public class Main
  {   
        
     static class FastReader{
  
         BufferedReader br;
         StringTokenizer st;
  
         public FastReader(){
  
         br=new BufferedReader(new InputStreamReader(System.in));
  
  
         }
  
         String next(){
  
         while(st==null||!st.hasMoreTokens()){
           
           try{
  
            st=new StringTokenizer(br.readLine());
  
           }
           catch(IOException e){
  
              e.printStackTrace();
           }
             
  
  
  
         }
         return st.nextToken();}
  
        long nextLong(){ return Long.parseLong(next());}
  
        int nextInt(){ return Integer.parseInt(next());}
  
  
         }
       
     static <t>void print(t o){
      System.out.println(o);
     }
      
     static boolean islapindrome(String s){
  
         int fhalf[]=new int[26];
         int shalf[]=new int[26];
  
          int i=0,j=s.length()-1;
          while(i<j){
             fhalf[s.charAt(i)-'a']++;
             shalf[s.charAt(j)-'a']++;
     i++;
     j--;
     
  
          }
  
          for(int k=0;k<26;k++){
            if(fhalf[k]!=shalf[k])return false;
          }
      return true;
  
  
  
  
     }
  
      static int mod=(int)1e9+7;
      static class pair{
          int a;
          int ele;
          public pair(int a,int ele)
          {
              this.a=a;
              this.ele=ele;
          }
      }
  
    public static void main (String args[]) throws IOException{
    try{
      System.setIn(new FileInputStream("input.txt"));
      System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } 
      catch (Exception e) {
      System.err.println("Error");
       }
       
       
       FastReader sc=new FastReader();
       int tt=sc.nextInt();
        while(tt-->0)
        {
            int n=sc.nextInt();
             long sum=0; 
            int arr[]=new int[n];
            for(int i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                sum+=arr[i];
            }
           if(sum%n==0)
           {
               System.out.println(0);
           }
           else{
               System.out.println(1);
           }
  
        } 
  
  
         
  
  
  
  
      }
      
      
      
      static void reverse(int[] arr, int from, int till) {
          for (int i = from, j = till; i < j; i++, j--) {
              swap(arr, i, j);
          }
      }
  
      static void swap(int[] arr, int a, int b) {
          int tmp = arr[a];
          arr[a] = arr[b];
          arr[b] = tmp;
      }
  
      
      
      
      void sieveOfEratosthenes(int n)
      {
          boolean prime[] = new boolean[n+1];
          for(int i=0;i<=n;i++)
              prime[i] = true;
           
          for(int p = 2; p*p <=n; p++)
          {
              if(prime[p] == true)
              {
                  for(int i = p*p; i <= n; i += p)
                      prime[i] = false;
              }
          }
          for(int i = 2; i <= n; i++)
          {
              if(prime[i] == true)
                  System.out.print(i + " ");
          }
      }
      static long gcd(long a,long b)
      {
          if(b==0) return a;
          
          return gcd(b,a%b);
      }
      static boolean isprime(int n)
      {
          if(n<=1)
           return false;
          
          if(n<=3)
           return true;
          
          if(n%2==0||n%3==0)
           return false;
          
          for(int i=5;i*i<=n;i=i+6)
          {
              if(n%i==0||n%(i+2)==0)
                return false;
          }
          return true;
      }
  
  
  
     }
   