import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # 出発時に支払うことに統一 N, M = map(int, readline().split()) C = np.array([0] + read().split() + [0], np.float64) p = 1 / M mat = np.eye(N) for n in range(N - 1): for i in range(1, M + 1): to = n + i if to > N - 1: to = 2 * (N - 1) - to mat[n, to] -= p dp_0 = np.linalg.solve(mat, C) dp_1 = np.zeros(N) for n in range(N - 1, -1, -1): # 魔法権利があるときのコスト期待値 if n + M >= N - 1: dp_1[n] = C[n] else: # 魔法を使う x = dp_0[n + 1:n + M + 1].min() # 適当にすすむ y = dp_1[n + 1:n + M + 1].mean() dp_1[n] = min(x, y) + C[n] print(dp_1[0])