#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0;
  cin >> n;
  int arr[n], f[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  sort(arr, arr + n);
  int quo = sum / n;
  int rem = sum % n;
  for (int i = 0; i < n; i++) {
    f[i] = quo;
  }
  int i = n - 1;
  while (rem--) {
    f[i]++;
    i--;
  }
  sum = 0;
  for (i = 0; i < n; i++) {
    sum += abs(f[i] - arr[i]);
  }
  cout << sum / 2 << endl;
  return 0;
}
