#include #include using namespace std; int main(){ int b, n; cin >> b >> n; int A[n]; for(int i = 0; i < n; i++) cin >> A[i]; sort(A, A+n); int mid = n/2; int ans = 0; for(int x : A) ans += abs(x-A[mid]); if(n%2 == 0){ mid--; int ans2 = 0; for(int x : A) ans2 += abs(x-A[mid]); ans = min(ans, ans2); } cout << ans << endl; return 0; }