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 sys
  import math
  import itertools
  import functools
  import collections
  import operator
  import fileinput
  import copy
  import string
  
  ORDA = 97  # a
  
  
  def ii(): return int(input())
  
  
  def mi(): return map(int, input().split())
  
  
  def li(): return list(map(int, input().split()))
  
  
  def lcm(a, b): return abs(a * b) // math.gcd(a, b)
  
  
  def revn(n): return str(n)[::-1]
  
  
  def dd(): return collections.defaultdict(int)
  
  
  def ddl(): return collections.defaultdict(list)
  
  
  def sieve(n):
      if n < 2: return list()
      prime = [True for _ in range(n + 1)]
      p = 3
      while p * p <= n:
          if prime[p]:
              for i in range(p * 2, n + 1, p):
                  prime[i] = False
          p += 2
      r = [2]
      for p in range(3, n + 1, 2):
          if prime[p]:
              r.append(p)
      return r
  
  
  def divs(n, start=2):
      r = []
      for i in range(start, int(math.sqrt(n) + 1)):
          if (n % i == 0):
              if (n // i == i):
                  r.append(i)
              else:
                  r.extend([i, n // i])
      return r
  
  
  def divn(n, primes):
      divs_number = 1
      for i in primes:
          if n == 1:
              return divs_number
          t = 1
          while n % i == 0:
              t += 1
              n //= i
          divs_number *= t
  
  
  def prime(n):
      if n == 2: return True
      if n % 2 == 0 or n <= 1: return False
      sqr = int(math.sqrt(n)) + 1
      for d in range(3, sqr, 2):
          if n % d == 0: return False
      return True
  
  
  def convn(number, base):
      new_number = 0
      while number > 0:
          new_number += number % base
          number //= base
      return new_number
  
  
  def cdiv(n, k): return n // k + (n % k != 0)
  
  
  def ispal(s):
      for i in range(len(s) // 2 + 1):
          if s[i] != s[-i - 1]:
              return False
      return True
  
  
  for _ in range(ii()):
      n = ii()
      a = li()
      if sum(a) % n:
          print(1)
      else:
          print(0)
  
  
  
  
  
  
  
  
  
  
  
  
  
  