#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n;
int a[100010];
bool cmp(int e1, int e2) { return e1 > e2; }
int main(int argc, char *argv[]) {
  cin >> n;
  int sum = 0;
  int _max = 0;
  int _min = INF;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int avg = sum / n;
  if (sum % n) avg++;
  sort(a, a + n, cmp);
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > avg) ans1 += a[i] - avg;
  }
  if (sum % n) avg--;
  for (int i = 0; i < n; i++) {
    if (a[i] < avg) ans2 += avg - a[i];
  }
  cout << max(ans1, ans2) << endl;
  return 0;
}
