#include #include #include #include #include int main() { int box_num, having_candy_num; std::cin >> having_candy_num >> box_num; std::vector boxes(box_num); for (int i = 0; i < box_num; i++) std::cin >> boxes[i]; long long ave = round(std::accumulate(boxes.begin(), boxes.end(), 0L) / static_cast(box_num)); long long count = 0; for (size_t j = 0; j < boxes.size(); j++) { if (boxes[j] > ave) { count += boxes[j] - ave; } else if (boxes[j] < ave) { count += ave - boxes[j]; } } std::cout << count << std::endl; return 0; }