#include <bits/stdc++.h>
int n, m[100000];
int main() {
  int i, sum = 0, a, b, count1 = 0, count2 = 0, count = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &m[i]);
  for (i = 0; i < n; i++) sum += m[i];
  if (sum % n) {
    a = sum / n;
    b = a + 1;
    for (i = 0; i < n; i++) {
      if (m[i] > b) count1 += (m[i] - b);
      if (m[i] < a) count2 += (a - m[i]);
      count = (count1 > count2) ? count1 : count2;
    }
  } else {
    a = sum / n;
    for (i = 0; i < n; i++)
      if (m[i] < a) count += (a - m[i]);
  }
  printf("%d", count);
  return 0;
}
