#include using namespace std; #define rep(i,a,b) for(int i=a;i=b;i--) int N, M; int C[101]; //----------------------------------------------------------------- int main() { cin >> N >> M; rep(i, 2, N) cin >> C[i]; vector dp(N + 1, 100); rep(t, 0, 10000) { vector pd(N + 1, 0); rep(i, 1, N) { pd[i] = C[i]; rep(j, 1, M + 1) { int ii = i + j; if (ii <= N) pd[i] += dp[ii] / M; else pd[i] += dp[N - (ii - N)] / M; } } swap(dp, pd); } vector dp2(N + 1, 0); rrep(i, N, 1) { if (N - i <= M) dp2[i] = C[i]; else { double use = 1e20; rep(j, 1, M + 1) use = min(use, dp[i + j]); double nonuse = 0; rep(j, 1, M + 1) nonuse += dp2[i + j] / M; dp2[i] = C[i] + min(use, nonuse); } } printf("%.10f\n", dp2[1]); }