import java.io.*; import java.util.*; public class Main_yukicoder463 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n - 2; i++) { a[i + 1] = sc.nextInt(); } int lim = 1_000; double[][] ex = new double[lim][n]; for (int k = 1; k < lim; k++) { for (int i = n - 2; i >= 0; i--) { for (int j = 1; j <= m; j++) { int tmp = i + j; if (i + j > n - 1) { tmp = n - 1 - (tmp - (n - 1)); } ex[k][i] += (a[tmp] + ex[k - 1][tmp]) / m; } } } // pr.printf("%.10f\n", ex[lim - 1][0]); final double INF = Double.MAX_VALUE; double[] dp = new double[n]; Arrays.fill(dp, INF); for (int i = n - 2; i >= 0; i--) { double dtmp = 0; // for (int j = 1; j <= m && i + j < n; j++) { for (int j = 1; j <= m; j++) { int tmp = i + j; if (i + j > n - 1) { tmp = n - 1 - (tmp - (n - 1)); } else { dp[i] = Math.min(dp[i], ex[lim - 1][i + j] + a[i + j]); } dtmp += (a[tmp] + dp[tmp]) / m; } dp[i] = Math.min(dp[i], dtmp); } pr.printf("%.10f\n", dp[0]); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }