package 二〇一七年三月二十四日;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class 纸牌移动1 {
public static void main(String[] args) {
List<Integer> list =
new ArrayList<Integer>();
Scanner s =
new Scanner(System.
in);
int sum =
0;
int n = s.nextInt();
for (
int x =
0; x < n; x++) {
list.add(s.nextInt());
sum += list.
get(x);
}
int avg = sum / n;
int count =
0;
for (
int x =
0; x < list.size() -
1; x++) {
count++;
list.
set(x +
1, list.
get(x +
1) + list.
get(x) - avg);
}
System.
out.println(count);
}
}