#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
template <class T, class Cost> struct MonotoneMinDP {
int n;
Cost cost;
vector<T> ts;
vector<int> par;
MonotoneMinDP() {}
MonotoneMinDP(int n_, Cost cost_) : n(n_), cost(cost_) {
ts.assign(n + 1, T());
par.assign(n + 1, -1);
update(0, n);
rec(0, n);
}
void update(int l, int r) {
assert(l<r);
const T t = ts[l] + cost(l, r);
if (!~par[r] || ts[r] > t) {
ts[r] = t;
par[r] = l;
}
}
// precondition: ts[0, l] is determined
// precondition: transitions from [0, l] to r is checked
// postcondition: ts[0, r] is determined
void rec(int l, int r) {
if (r - l <= 1) return;
const int m = (l + r) / 2;
for (int i = max(par[l], 0); i <= max(par[r], 0); ++i) update(i, m);
//!?
if(par[l]>par[r])check(par[l],m);
rec(l, m);
for (int i = l + 1; i <= m; ++i) update(i, r);
rec(m, r);
}
};
template <class T, class Cost> MonotoneMinDP<T, Cost> monotoneMinDP(int n, Cost cost) {
return MonotoneMinDP<T, Cost>(n, cost);
}
template <class D, class F> auto goldenMax(D a, D b, int numIters, F f) {
constexpr D GOLD = (3.0L - sqrt(5.0L)) / 2.0L;
D c = a + GOLD * (b - a), d = b - GOLD * (b - a);
auto fc = f(c), fd = f(d);
for (int iter = 0; iter < numIters; ++iter) {
if (fc < fd) { a = c; c = d; d = b - GOLD * (b - a); fc = fd; fd = f(d); }
else { b = d; d = c; c = a + GOLD * (b - a); fd = fc; fc = f(c); }
}
return make_pair(fc, c);
}
using Double = long double;
int N, M;
vector<Int> S;
int main() {
for (; ~scanf("%d%d", &N, &M); ) {
S.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%lld", &S[i]);
}
sort(S.begin(), S.end());
vector<Int> SSum(N + 1, 0);
for (int i = 0; i < N; ++i) {
SSum[i + 1] = SSum[i] + S[i];
}
auto lag = [&](const Double pena) {
return monotoneMinDP<Double>(N, [&](int l, int r) -> Double {
return sqrt((Double)((r - l) * (SSum[r] - SSum[l]))) + pena;
});
};
// cost <= sqrt(N SSum[N]) <= (2*10^5) * sqrt(10^5)
const auto res = goldenMax(-2e8L, +2e8L, 200, [&](const Double pena) -> Double {
const auto m = lag(pena);
return m.ts[N] - M * pena;
});
const auto m = lag(res.second);
Double ans = 0.0;
for (int r = N; r; ) {
const int l = m.par[r];
assert(0<=l);
assert(l<r);
assert(r<=N);
ans += sqrt((Double)((r - l) * (SSum[r] - SSum[l])));
r = l;
}
printf("%.20Lf\n", (long double)ans);
}
return 0;
}