#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long;using pii=pair; using vb=vector;using vs=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templateT read(){T t;cin>>t;return t;} templateostream&operator<<(ostream&o,const pair&p){o<<'('< bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } void Main() { int n = read(); int m = read(); vi C(n); rep(i, 1, n-1) C[i] = read(); int T = 1000; vvvd memo(n, vvd(2, vd(T+1, -1))); function dfs = [&](int cur, int used, int depth) -> double { if (cur == n - 1) return 0; if (depth == T) return C[cur]; if (memo[cur][used][depth] != -1) return memo[cur][used][depth]; double u = inf; double v = 0; if (used == 0) { rep(d, 1, m + 1) { int nex = cur + d; if (nex >= n) break; double ret = dfs(nex, 1, depth + 1); u = min(u, ret); } } { rep(d, 1, m + 1) { int nex = cur + d; if (nex >= n) nex = (n - 1) * 2 - nex; v += dfs(nex, used, depth + 1) / m; } } return memo[cur][used][depth] = min(u, v) + C[cur]; }; double ans = dfs(0, 0, 0); cout << fixed << setprecision(10) << ans << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }