27 lines
456 B
C++
27 lines
456 B
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
int main(){
|
|
int n;
|
|
cin >> n;
|
|
vector<int> a(n);
|
|
int sum = 0;
|
|
for(int i = 0; i < n; i++){
|
|
cin >> a[i];
|
|
sum += a[i];
|
|
}
|
|
int avg = sum / n;
|
|
int js = 0;
|
|
for(int i = 0; i < n - 1; i++){
|
|
if(a[i] != avg){
|
|
int tmp = a[i] - avg;
|
|
a[i] = avg;
|
|
a[i + 1] += tmp;
|
|
js++;
|
|
}
|
|
}
|
|
cout << js << endl;
|
|
return 0;
|
|
}
|