#include // #include using namespace std; // using namespace atcoder; using lint = long long; templateusing graph = vector>; #define endl '\n' int const INF = 1<<30; lint const INF64 = 1LL<<62; lint const mod = 1e9+7; //long const mod = 998244353; int main(){ lint n,k; cin >> n >> k; lint a[n]; for(int i=0;i> a[i]; lint summ = 0; lint plus = 0; for(int i=0;i abs(a[right+1] - center)){ left++; right++; plus -= abs(a[left] - center); plus += abs(a[right+1] - center); }else{ break; } } ans = min(ans, plus*2 - summ); } cout << ans << endl; }