#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  int s[n];
  fill_n(s, n, sum / n);
  int z = sum % n;
  for (int i = n - 1; i >= 0; --i) {
    if (z <= 0) break;
    s[i]++;
    z--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(s[i] - a[i]);
  }
  ans /= 2;
  cout << ans;
}
