#include <bits/stdc++.h>
using namespace std;
int v[100000];
int main(void) {
  int n;
  int sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    sum += v[i];
  }
  int mean = sum / n;
  int r = sum % n;
  int a, b;
  if (r == 0) {
    a = b = mean;
  } else {
    a = mean;
    b = mean + 1;
  }
  int l = 0, g = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] < a)
      l += a - v[i];
    else if (v[i] > b)
      g += v[i] - b;
  }
  printf("%d\n", max(l, g));
}
