#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, t1, t2, sum1 = 0, sum2 = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  t1 = sum / n;
  if (sum % n) {
    t2 = t1 + 1;
  } else {
    t2 = t1;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (t1 - a[i] > 0) {
      sum1 += (t1 - a[i]);
    }
    if (t2 - a[i] < 0) {
      sum2 += (a[i] - t2);
    }
  }
  cout << max(sum1, sum2);
}
