#include #include #include using namespace std; int main(){ int N, K; cin >> N >> K; vector v; for(int i = 0; i < N; i++){ int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end()); double Max, Min; double ans; if(K % 2 == 0 || K == 3 || K == N || N >= K + 2){ Max = v[N-1]; Min = v[0]; }else if(K % 2 == 1 && K != 3){ Max = v[N-1]; Min = (v[0] + v[1]) / 2; } ans = Max - Min; cout << ans << endl; return 0; }