#include using namespace std; vector A; double f(double x){ double cnt = 0; for(int i = 0 ; i < A.size() ; i++) cnt += fabs(A[i]-x); return -cnt; } double search(double left, double right) { for (int loop = 0; loop < 1919; ++loop){ if (f((left * 2 + right) / 3) > f((left + right * 2) / 3)){ right = (left + right * 2) / 3; } else { left = (left * 2 + right) / 3; } } return (right + left) * 0.5; } int main(){ long long B,N; cin >> B >> N; vector C(N); long long sum = B; for(int i = 0 ; i < N ; i++){ cin >> C[i]; sum += C[i]; } ::A = C; sum /= N; //cout << search(0,sum) << endl; //cout << f(720) << "<" << endl; cout << (long long)(-f(search(0,sum))+1e-9) << endl; }