#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m[100000];
  int ma, mb, total = 0;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    total += m[i];
  }
  ma = total / n;
  mb = (total + n - 1) / n;
  int toohigh = 0, toolow = 0;
  for (int i = 0; i < n; i++)
    if (m[i] > mb)
      toohigh += m[i] - mb;
    else if (m[i] < ma)
      toolow += ma - m[i];
  cout << max(toohigh, toolow) << endl;
}
