#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, cnt = 0, sum = 0, ans = 0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    sum += v[i];
  }
  vector<int> norm(n, sum / n);
  sort(v.begin(), v.end());
  cnt = 1;
  while (cnt <= sum % n) {
    ++norm[n - cnt];
    ++cnt;
  }
  for (int i = 0; i < n; ++i) {
    ans += abs(norm[i] - v[i]);
  }
  cout << ans / 2;
}
