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: import java.io.*;
  import java.util.Arrays;
  import java.util.Locale;
  import java.util.StringTokenizer;
  
  public class A {
  
      private final boolean MULTI_TEST = true;
      private final String FILE_NAME = "";
  
      private void solve() {
          int conC = 0;
          int conN = 0;
          int n = ri();
          int[] a = ria(n);
          sort(a);
          long sum = sum(a);
          if(sum % a.length == 0) out.println(0); else out.println(1);
      }
  
      //////////////////////////////////////////////////////////////////
  
      long sqrtLong(long x) {
          long root = (long) Math.sqrt(x);
          while (root * root > x) --root;
          while ((root + 1) * (root + 1) <= x) ++root;
          return root;
      }
  
      int gcd(int a, int b) {
          if (b == 0)
              return a;
          else
              return gcd(b, a % b);
      }
  
      int lcm(int a, int b) {
          return a / gcd(a, b) * b;
      }
  
      int phi(int n) {
          int result = n;
          for (int i = 2; i * i <= n; ++i)
              if (n % i == 0) {
                  while (n % i == 0)
                      n /= i;
                  result -= result / i;
              }
          if (n > 1)
              result -= result / n;
          return result;
      }
  
      int factmod(int n, int p) {
          int res = 1;
          while (n > 1) {
              res = (res * ((n / p) % 2 == 1 ? p - 1 : 1)) % p;
              for (int i = 2; i <= n % p; ++i)
                  res = (res * i) % p;
              n /= p;
          }
          return res % p;
      }
  
      int binpow(int a, int n) {
          int res = 1;
          while (n != 0) {
              if ((n & 1) != 0)
                  res *= a;
              a *= a;
              n >>= 1;
          }
          return res;
      }
  
      String solPyatnashki() {
          int a[] = new int[16];
          for (int i = 0; i < 16; ++i)
              a[i] = ri();
  
          int inv = 0;
          for (int i = 0; i < 16; ++i)
              if (a[i] != 0)
                  for (int j = 0; j < i; ++j)
                      if (a[j] > a[i])
                          ++inv;
          for (int i = 0; i < 16; ++i)
              if (a[i] == 0)
                  inv += 1 + i / 4;
  
  
          return ((inv & 1) != 0 ? "No Solution" : "Solution Exists");
      }
  
      boolean isPrime(int number) {
          for (int i = 2; i * i <= number; i++) {
              if (number % i == 0) {
                  return false;
              }
          }
          return number > 1;
      }
  
      boolean[] primes(int border) {
          boolean[] isPrimes = new boolean[border + 1];
          Arrays.fill(isPrimes, true);
          isPrimes[0] = false;
          isPrimes[1] = false;
          for (int i = 2; i < border + 1; i++) {
              if (!isPrimes[i]) continue;
              for (int k = i * 2; k < border; k += i) {
                  isPrimes[k] = false;
              }
          }
          return isPrimes;
      }
  
      void sort(int[] arr) {
          Integer[] a = new Integer[arr.length];
          for (int i = 0; i < arr.length; i++) {
              a[i] = arr[i];
          }
          Arrays.sort(a);
          for (int i = 0; i < a.length; i++) {
              arr[i] = a[i];
          }
      }
  
      void sort(long[] arr) {
          Long[] a = new Long[arr.length];
          for (int i = 0; i < arr.length; i++) {
              a[i] = arr[i];
          }
          Arrays.sort(a);
          for (int i = 0; i < a.length; i++) {
              arr[i] = a[i];
          }
      }
  
      int max(int[] a) {
          int max = Integer.MIN_VALUE;
          for (int i = 0; i < a.length; i++) {
              if (a[i] > max) max = a[i];
          }
          return max;
      }
  
      long max(long[] a) {
          long max = Long.MIN_VALUE;
          for (int i = 0; i < a.length; i++) {
              if (a[i] > max) max = a[i];
          }
          return max;
      }
  
      int min(int[] a) {
          int min = Integer.MAX_VALUE;
          for (int i = 0; i < a.length; i++) {
              if (a[i] < min) min = a[i];
          }
          return min;
      }
  
      long min(long[] a) {
          long min = Long.MAX_VALUE;
          for (int i = 0; i < a.length; i++) {
              if (a[i] < min) min = a[i];
          }
          return min;
      }
  
      long sum(int[] a) {
          long s = 0;
          for(int i = 0; i < a.length; i++) {
              s+=a[i];
          }
          return s;
      }
  
      long fastMod(String s1, long n2) {
          long num = 0;
          for (int i = 0; i < s1.length() - 1; i++) {
              num += Integer.parseInt(String.valueOf(s1.charAt(i)));
              num *= 10;
              if (num >= n2) {
                  num = num % n2;
              }
          }
          return (num + Integer.parseInt(String.valueOf(s1.charAt(s1.length() - 1)))) % n2;
      }
  
      //////////////////////////////////////////////////////////////////
  
      private boolean yesNo(boolean yes) {
          return yesNo(yes, "YES", "NO");
      }
  
      private boolean yesNo(boolean yes, String yesString, String noString) {
          out.println(yes ? yesString : noString);
          return yes;
      }
  
      //////////////////////////////////////////////////////////////////
  
      private long rl() {
          return Long.parseLong(rs());
      }
  
      private double rd() {
          return Double.parseDouble(rs());
      }
  
      private int[] ria(int n) {
          int[] a = new int[n];
          for (int i = 0; i < n; ++i) a[i] = ri();
          return a;
      }
  
      private int ri() {
          return Integer.parseInt(rs());
      }
  
      private String rs() {
          while (!tok.hasMoreTokens()) {
              String nextLine = readLine();
              if (null == nextLine) return null;
              tok = new StringTokenizer(nextLine);
          }
  
          return tok.nextToken();
      }
  
      private String readLine() {
          try {
              return in.readLine();
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
      }
  
      //////////////////////////////////////////////////////////////////
  
      private BufferedReader in;
      private StringTokenizer tok;
      private PrintWriter out;
  
      private void initFileIO(String inputFileName, String outputFileName) throws FileNotFoundException {
          in = new BufferedReader(new FileReader(inputFileName));
          out = new PrintWriter(outputFileName);
      }
  
      private void initConsoleIO() throws IOException {
          in = new BufferedReader(new InputStreamReader(System.in));
          out = new PrintWriter(System.out);
      }
  
      private void initIO() throws IOException {
          Locale.setDefault(Locale.US);
  
          if (!FILE_NAME.isEmpty()) {
              initFileIO(FILE_NAME + ".in", FILE_NAME + ".out");
          } else {
              if (new File("input.txt").exists()) {
                  initFileIO("input.txt", "output.txt");
              } else {
                  initConsoleIO();
              }
          }
  
          tok = new StringTokenizer("");
      }
  
      //////////////////////////////////////////////////////////////////
  
      private void run() {
          try {
              long timeStart = System.currentTimeMillis();
              initIO();
              if (MULTI_TEST) {
                  int t = ri();
                  while (t-- > 0) {
                      solve();
                      out.flush();
                  }
              } else
                  solve();
              out.close();
              long timeEnd = System.currentTimeMillis();
              System.err.println("Time(ms) = " + (timeEnd - timeStart));
          } catch (Exception e) {
              e.printStackTrace();
              throw new RuntimeException(e);
          }
      }
  
      public static void main(String[] args) {
          new A().run();
      }
  
      ///////////////////////////////////////////////////////////////////
  }
  