#include <bits/stdc++.h>
using namespace std;
int n, arr[100000 * 2 + 5], s, lim, cn, mv;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s += arr[i];
  };
  lim = s / n;
  cn = (s % n);
  sort(arr, arr + n);
  reverse(arr, arr + n);
  for (int i = 0; i < n; i++) mv += abs(arr[i] - lim - ((i < cn) ? 1 : 0));
  cout << mv / 2 << endl;
  return 0;
}
