#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = LLONG_MAX - 100000;
long long pw(long long x, long long y, long long p = inf) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long invmod(long long a, long long m = mod) { return pw(a, m - 2, m); }
long long cl(long long a, long long x) {
  return a % x == 0 ? a / x : a / x + 1;
}
void run_time_terror(long long case_no = 0) {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long sm = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    sm += a[i];
  }
  long long avg = sm / n;
  long long ans = 0;
  long long left = sm % n;
  vector<long long> val(n, avg);
  for (long long i = 0; i < left; ++i) {
    val[i]++;
  }
  sort(a.begin(), a.end());
  sort(val.begin(), val.end());
  for (long long i = 0; i < n; ++i) {
    ans += abs(a[i] - val[i]);
  }
  cout << cl(ans, 2);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed);
  cout << setprecision(0);
  long long tt = 1;
  for (long long case_no = 1; case_no <= tt; case_no++) {
    run_time_terror(case_no);
  }
  return 0;
}
