#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, inp, sum = 0;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &inp);
    v.push_back(inp);
    sum += inp;
  }
  sort(v.begin(), v.end());
  if (sum % n == 0) {
    int tem = sum / n, ans = 0;
    for (int i = 0; i < n; i++) ans += abs(v[i] - tem);
    cout << ans / 2;
    return 0;
  } else {
    int tem = sum / n, ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++)
      if (v[i] <= tem)
        ans1 += tem - v[i];
      else
        ans2 += v[i] - tem - 1;
    cout << max(ans1, ans2);
    return 0;
  }
  return 0;
}
