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: #include <bits/stdc++.h>
  using namespace std;
  const long long mod = 1e9 + 7;
  void _print(long long t) { cerr << t; }
  void _print(int t) { cerr << t; }
  void _print(string t) { cerr << t; }
  void _print(char t) { cerr << t; }
  void _print(long double t) { cerr << t; }
  void _print(double t) { cerr << t; }
  void _print(unsigned long long t) { cerr << t; }
  template <class T, class V>
  void _print(pair<T, V> p);
  template <class T>
  void _print(vector<T> v);
  template <class T>
  void _print(set<T> v);
  template <class T, class V>
  void _print(map<T, V> v);
  template <class T>
  void _print(multiset<T> v);
  template <class T, class V>
  void _print(pair<T, V> p) {
    cerr << "{";
    _print(p.first);
    cerr << ",";
    _print(p.second);
    cerr << "}";
  }
  template <class T>
  void _print(vector<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(set<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(multiset<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T, class V>
  void _print(map<T, V> v) {
    cerr << "[ ";
    for (auto i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T, class V>
  void _print(unordered_map<T, V> v) {
    cerr << "[ ";
    for (auto i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  long long gcd(long long a, long long b) {
    if (b > a) {
      return gcd(b, a);
    }
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }
  long long expo(long long a, long long b, long long mod) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = (res * a) % mod;
      a = (a * a) % mod;
      b = b >> 1;
    }
    return res;
  }
  long long expo(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = (res * a);
      a = (a * a);
      b = b >> 1;
    }
    return res;
  }
  void extendgcd(long long a, long long b, long long *v) {
    if (b == 0) {
      v[0] = 1;
      v[1] = 0;
      v[2] = a;
      return;
    }
    extendgcd(b, a % b, v);
    long long x = v[1];
    v[1] = v[0] - v[1] * (a / b);
    v[0] = x;
    return;
  }
  long long mminv(long long a, long long b) {
    long long arr[3];
    extendgcd(a, b, arr);
    return arr[0];
  }
  long long mminvprime(long long a, long long b) { return expo(a, b - 2, b); }
  bool revsort(long long a, long long b) { return a > b; }
  void swap(int &x, int &y) {
    int temp = x;
    x = y;
    y = temp;
  }
  long long combination(long long n, long long r, long long m, long long *fact,
                        long long *ifact) {
    long long val1 = fact[n];
    long long val2 = ifact[n - r];
    long long val3 = ifact[r];
    return (((val1 * val2) % m) * val3) % m;
  }
  void google(int t) { cout << "Case #" << t << ": "; }
  vector<int> sieve(int n) {
    int *arr = new int[n + 1]();
    vector<int> vect;
    for (int i = 2; i <= n; i++)
      if (arr[i] == 0) {
        vect.push_back(i);
        for (long long j = (long long(i) * long long(i)); j <= n; j += i)
          arr[j] = 1;
      }
    return vect;
  }
  long long phin(long long n) {
    long long number = n;
    if (n % 2 == 0) {
      number /= 2;
      while (n % 2 == 0) n /= 2;
    }
    for (long long i = 3; i <= sqrt(n); i += 2) {
      if (n % i == 0) {
        while (n % i == 0) n /= i;
        number = (number / i * (i - 1));
      }
    }
    if (n > 1) number = (number / n * (n - 1));
    return number;
  }
  long long inv(long long a) { return expo(a, mod - 2, mod); }
  long long add(long long a, long long b) { return (a + b) % mod; }
  long long sub(long long a, long long b) { return (a - b + mod) % mod; }
  long long mul(long long a, long long b) { return (a * b) % mod; }
  long long divi(long long a, long long b) { return (a * inv(b)) % mod; }
  long long nCr(long long n, long long r) {
    if (r > n) return 0;
    r = min(r, n - r);
    vector<long long> dp(r + 1, 0);
    dp[0] = 1;
    for (long long i = 1; i <= n; i++) {
      for (long long j = min(r, i); j >= 1; j--) {
        dp[j] = (dp[j - 1] + dp[j] + mod) % mod;
      }
    }
    return dp[r];
  }
  long long sum2(long long a[], int n) {
    long long initial_sum = 0;
    return accumulate(a, a + n, initial_sum);
  }
  void solve() {
    int t;
    cin >> t;
    while (t--) {
      long long n;
      cin >> n;
      long long s = 0;
      for (long long(i) = 0; (i) < (long long)(n); ++(i)) {
        long long a;
        cin >> a;
        s += a;
      }
      cout << (s % n ? 1 : 0) << endl;
    }
  }
  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
  }
  