#include <bits/stdc++.h>
using namespace std;
long long n, tab[100001], sum, ans, up, down;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int a = 1; a <= n; a++) {
    cin >> tab[a];
    sum += tab[a];
  }
  if (sum % n) {
    for (int a = 1; a <= n; a++) {
      if (tab[a] <= (sum / n))
        up += (sum / n) - tab[a];
      else
        down += tab[a] - (sum / n) - 1;
    }
    cout << max(up, down);
  } else {
    for (int a = 1; a <= n; a++) {
      if (tab[a] <= sum / n)
        ans += (sum / n) - tab[a];
      else
        ans += tab[a] - (sum / n);
    }
    cout << (ans >> 1);
  }
  return 0;
}
