#include <bits/stdc++.h>
using namespace std;
int n, ar[100005];
int main() {
  cin >> n;
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    s += ar[i];
  }
  int div = s / n;
  int mod = s % n;
  int ans = 0;
  sort(ar, ar + n);
  reverse(ar, ar + n);
  for (int i = 0; i < mod; i++) {
    ans += abs(ar[i] - div - 1);
  }
  for (int i = mod; i < n; i++) {
    ans += abs(ar[i] - div);
  }
  cout << ans / 2 << endl;
  return 0;
}
