#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int total_load = accumulate(a.begin(), a.end(), 0);
  int m0 = total_load / n;
  int more_load_servers = total_load % n;
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n - more_load_servers; i++) {
    ans += abs(a[i] - m0);
  }
  for (int i = n - more_load_servers; i < n; i++) {
    ans += abs(a[i] - (m0 + 1));
  }
  cout << ans / 2 + ans % 2 << endl;
  return 0;
}
