#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100005], sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int avg = sum / n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < avg) {
      ans += avg - a[i];
    }
  }
  int ans2 = 0;
  if (avg % n != 0) {
    avg++;
    for (int i = 0; i < n; i++) {
      if (a[i] > avg) {
        ans2 += a[i] - avg;
      }
    }
  }
  cout << max(ans, ans2);
}
