#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int tt, n;
  tt = 1;
  cin >> tt;
  while (tt--) {
    cin >> n;
    long long int a[n], s = 0;
    for (int i = 0; i < n; i++) cin >> a[i], s += a[i];
    if (s < n)
      cout << 2 * (n - s) << ("\n");
    else if (s % n == 0)
      cout << "0" << ("\n");
    else
      cout << 2 * n + 1 << ("\n");
  }
  return 0;
}
