text: /*
      /\ In The Name Of Allah /\
      Author : Jawahiir Nabhan
  */
  #include <bits/stdc++.h>
  #define pb push_back
  using namespace std;
  typedef long long ll;
  const char nl = '\n';
  
  int main()
  {
      int T; cin>> T;
      while(T--)
      {
          int N; cin>> N;
          vector <int> a(N);
          for(int i = 0;i < N;i++) cin>> a[i];
          int s = accumulate(a.begin(),a.end(), 0);
          if(s % N == 0) cout<< 0 << nl;
          else cout<< 1 << nl;
      }
  }
  