#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  int tab[N];
  for (int i = 0; i < N; i++) {
    cin >> tab[i];
    sum += tab[i];
  }
  int goal[N];
  for (int i = 0; i < N; i++) goal[i] = sum / N + (sum % N > N - i - 1);
  sort(tab, tab + N);
  int res = 0;
  for (int i = 0; i < N; i++) res += abs(tab[i] - goal[i]);
  cout << res / 2 << endl;
}
