#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m[100000];
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> m[i];
    sum += m[i];
  }
  int mean = sum / n;
  int rest = sum % n;
  int a = n - rest;
  int b = rest;
  int operations = 0;
  for (int i = 0; i < n; ++i) {
    if (m[i] >= mean + 1) {
      b--;
      if (b >= 0) {
        operations += abs(m[i] - mean - 1);
      } else {
        operations += abs(mean - m[i]);
      }
    } else if (m[i] <= mean) {
      a--;
      if (a >= 0) {
        operations += abs(mean - m[i]);
      } else {
        operations += abs(m[i] - mean - 1);
      }
    }
  }
  cout << operations / 2;
}
