#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int Array[n];
  for (int i = (int)0; i < (int)n; ++i) cin >> Array[i];
  stable_sort(Array, Array + n);
  int Sum = accumulate(Array, Array + n, 0, plus<int>());
  int Middle = Sum / n;
  vector<int> a(n, Middle);
  int NewSum = Middle * n;
  int Diff = n - (Sum - NewSum);
  int Ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i >= Diff) {
      Ans += abs(Array[i] - (a[i] + 1));
    } else {
      Ans += abs(Array[i] - a[i]);
    }
  }
  cout << Ans / 2;
  return 0;
}
