n, m = map(int, input().split())
c = list(map(int, input().split()))

def move(i, k, n):
    total = i + k
    if total <= n:
        return total
    over = total - n
    cycle = 2 * (n - 1)
    over %= cycle
    if over == 0:
        return n
    if over <= (n - 1):
        return n - over
    else:
        return over - (n - 1) + 1

eps = 1e-12
max_iter = 1000000

DPA = [0.0] * (n + 1)
DPB = [0.0] * (n + 1)

for _ in range(max_iter):
    next_DPA = DPA.copy()
    next_DPB = DPB.copy()
    converged = True
    for i in range(n, 0, -1):
        if i == n:
            next_DPA[i] = 0.0
            next_DPB[i] = 0.0
            continue
        
        # Calculate DPB[i]
        sum_b = 0.0
        for k in range(1, m + 1):
            j = move(i, k, n)
            if 2 <= j <= n - 1:
                cost = c[j - 2]
            else:
                cost = 0
            sum_b += cost + DPB[j]
        new_dpb = sum_b / m
        if abs(new_dpb - next_DPB[i]) > eps:
            converged = False
        next_DPB[i] = new_dpb
        
        # Calculate DPA[i]
        sum_a = 0.0
        for k in range(1, m + 1):
            j = move(i, k, n)
            if 2 <= j <= n - 1:
                cost = c[j - 2]
            else:
                cost = 0
            sum_a += cost + DPA[j]
        val_normal = sum_a / m
        
        val_magic = float('inf')
        for k in range(1, m + 1):
            j = move(i, k, n)
            if 2 <= j <= n - 1:
                cost = c[j - 2]
            else:
                cost = 0
            current = cost + DPB[j]
            if current < val_magic:
                val_magic = current
        new_dpa = min(val_normal, val_magic)
        if abs(new_dpa - next_DPA[i]) > eps:
            converged = False
        next_DPA[i] = new_dpa
    
    DPA, next_DPA = next_DPA, DPA
    DPB, next_DPB = next_DPB, DPB
    
    if converged:
        break

print("{0:.10f}".format(DPA[1]))