#include using namespace std; typedef long long ll; ll C[10]; int main() { ll B, N; cin >> B >> N; ll sum = 0; for (ll i = 0; i < N; ++i) { cin >> C[i]; sum += C[i]; } ll avg = sum / N; ll ans = 0; for (ll i = 0; i < N; ++i) { if (C[i] > avg) ans += C[i] - avg; if (C[i] < avg) ans += avg - C[i]; } cout << ans << endl; }