#include <bits/stdc++.h>
using namespace std;
int main() {
  int data[100010];
  int n, i, ans, low, high, total;
  scanf("%d", &n);
  ans = 0;
  total = 0;
  for (i = 0; i < n; ++i) {
    scanf("%d", &data[i]);
    total += data[i];
  }
  if (total % n == 0) {
    low = high = total / n;
  } else {
    low = total / n;
    high = total / n + 1;
  }
  sort(data, data + n);
  ans = 0;
  int move = 0;
  for (i = n - 1; i >= 0; --i) {
    if (data[i] <= high) break;
    move += data[i] - high;
    ans += data[i] - high;
    data[i] = high;
  }
  for (i = 0; i < n; ++i) {
    if (data[i] < low) {
      move -= low - data[i];
      data[i] = low;
    }
  }
  if (move < 0) ans += move * -1;
  printf("%d\n", ans);
  return 0;
}
