It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!

When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a_1, a_2, ..., a_{n}, where a_{i} is the sleep time on the i-th day.

The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is $\frac{(3 + 4) +(4 + 7)}{2} = 9$.

You should write a program which will calculate average sleep times of Polycarp over all weeks.


-----Input-----

The first line contains two integer numbers n and k (1 ≤ k ≤ n ≤ 2·10^5).

The second line contains n integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5).


-----Output-----

Output average sleeping time over all weeks. 

The answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 6}. In particular, it is enough to output real number with at least 6 digits after the decimal point.


-----Examples-----
Input
3 2
3 4 7

Output
9.0000000000

Input
1 1
10

Output
10.0000000000

Input
8 2
1 2 4 100000 123 456 789 1

Output
28964.2857142857



-----Note-----

In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Data structures

Implementation


Solutions:
s = input()
s1 = s.split()
n = int(s1[0])
k = int(s1[1])
s = input()
s1 = s.split()
arr = []
for i in range(n):
	arr.append(int(s1[i]))
sum = 0
for i in range(k):
	sum += arr[i]
sum1 = sum
for i in range(k, n):
	sum += arr[i]
	sum -= arr[i - k]
	sum1 += sum
s = str(sum1 / (n - k + 1))
s += '000000'
print(s)


import math
import re
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a[:k])
res = s / (n - k + 1)
for i in range(n - k):
	s -= a[i]
	s += a[i + k]
	res += s / (n - k + 1)
print(res)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
weeks = n - k + 1
max_sum = min(weeks, k)
s = 0
for i in range(1, n + 1):
	m = max_sum
	if i < max_sum:
		m = i
	elif n - i + 1 < max_sum:
		m = n - i + 1
	s += m * h[i - 1]
s /= weeks
print(s)


(n, k) = map(int, input().split())
num = list(map(int, input().split()))
dp = []
dp.append(0)
for i in range(len(num)):
	dp.append(num[i] + dp[-1])
sum = 0.0
i = k
while i <= n:
	sum += dp[i] - dp[i - k]
	i += 1
weeks = n - k + 1
sum /= weeks
newsum = '%.10f' % sum
print(newsum)


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
(n, k) = mp()
a = lt()
s = sum(a[:k])
l = 0
for i in range(n - k + 1):
	l += s
	if i + k < n:
		s += a[i + k] - a[i]
pt(l / (n - k + 1))


(inputnumber, interval) = list(map(int, input().split()))
elementara = list(map(int, input().split()))
answer = 0
loop1 = 0
for i in range(len(elementara)):
	if i < min(interval, inputnumber - interval):
		answer += elementara[i] * (i + 1)
	elif i > len(elementara) - min(interval, inputnumber - interval) - 1:
		answer += elementara[i] * (len(elementara) - i)
	else:
		answer += min(interval, inputnumber - interval + 1) * elementara[i]
if inputnumber == 1 or interval == 1:
	print('{0:.7f}'.format(answer / inputnumber))
else:
	print('{0:.7f}'.format(answer / (inputnumber - interval + 1)))


def readInts():
	a = []
	for i in input().strip().split():
		a.append(int(i))
	return a

def calc():
	(n, k) = readInts()
	a = readInts()
	t = len(a)
	dp = [0] * n
	dp[0] = a[0]
	for i in range(1, t):
		dp[i] = dp[i - 1] + a[i]
	sum = dp[k - 1]
	for i in range(k, n):
		sum = sum + dp[i] - dp[i - k]
	sum = sum / (n - k + 1)
	return sum
print(round(calc(), 10))


import math

def averSleep(sleeps, n, k):
	result = 0
	for i in range(0, k - 1):
		if i >= math.floor(len(sleeps) / 2):
			if len(sleeps) % 2 == 1:
				result += sleeps[i] * min(n - k + 1, i)
			break
		result += sleeps[i] * min(n - k + 1, i + 1)
		result += sleeps[len(sleeps) - 1 - i] * min(n - k + 1, i + 1)
	result += sum(sleeps[k - 1:len(sleeps) - k + 1]) * k
	result /= n - k + 1
	return result
[n, k] = [int(x) for x in input().split()]
sleeps = [int(x) for x in input().split()]
print(averSleep(sleeps, n, k))


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
sm = 0
ds = [int(i) for i in input().split()]
for i in range(n):
	sm += min(i + 1, k, n - i, n - k + 1) * ds[i]
print(sm / (n - k + 1))


from itertools import *
(n, k) = list(map(int, input().split()))
a = list(accumulate([0] + list(map(int, input().split()))))
print(sum([a[i] - a[i - k] for i in range(k, n + 1)]) / (n - k + 1))


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
	ans += a[i] * min(min(k, n - k + 1), min(i, n - i - 1) + 1)
print(ans / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	temp = min(i + 1, k)
	temp -= k - min(n - i, k)
	ans += temp * a[i]
print('%.10f' % (ans / (n - k + 1)))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
(r, s, x) = (n - k + 1, 0, [])
x.append(a[0])
for i in range(1, n + 1):
	x.append(x[i - 1] + a[i - 1])
for i in range(k, n + 1):
	s += x[i] - x[i - k]
print(s / r)


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
summ = 0
k2 = n - k + 1
for i in range(n):
	summ += ai[i] * min(k2, k, i + 1, n - i)
print(summ / k2)


f = lambda : map(int, input().split())
(n, k) = f()
t = list(f())
h = s = sum(t[:k])
for i in range(n - k):
	s += t[k + i] - t[i]
	h += s
print(h / (n - k + 1))


import sys
from math import gcd, sqrt
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
inf = float('inf')
en = lambda x: list(enumerate(x))
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
arr = rr()
ans = 0
z = n - k + 1
for (i, j) in enumerate(arr, 1):
	ans += j * min(i, n - i + 1, z, k)
print(ans / z)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
b = []
s = 0
for i in range(n + 1):
	s += a[i]
	if i >= k:
		s -= a[i - k]
		b.append(s)
print(sum(b) / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = [0 for i in range(n)]
d[0] = a[0]
for i in range(1, n):
	d[i] = a[i] + d[i - 1]
cnt = 0
sm = 0
for i in range(k - 1, n):
	cnt += 1
	if i == k - 1:
		sm += d[i]
	else:
		sm += d[i] - d[i - k]
from decimal import Decimal
summa = Decimal(sm)
count = Decimal(cnt)
print(summa / count)


line = input().split()
n = int(line[0])
k = int(line[1])
nums = input().split()
for i in range(n):
	nums[i] = int(nums[i])
firstsum = 0
for i in range(k):
	firstsum += nums[i]
totsum = firstsum
for i in range(n - k):
	firstsum -= nums[i]
	firstsum += nums[k + i]
	totsum += firstsum
print(totsum / (n - k + 1))


(n, k) = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
temp = 0
total = 0
for i in range(n - k + 1):
	if i == 0:
		temp = sum(A[:k])
		total += temp
	else:
		temp -= A[i - 1]
		temp += A[i + k - 1]
		total += temp
ans = total / (n - k + 1)
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def main():
	if len(a) == 1:
		print(a[0])
		return
	if k == 1:
		print(sum(a) / len(a))
		return
	if n == k:
		print(sum(a))
		return
	i = 0
	result = 0
	if 2 * k - 1 <= n:
		while i < k - 1:
			result += (a[i] + a[-1 - i]) * (i + 1)
			i += 1
		result += sum(a[k - 1:-k + 1]) * k
		print(result / (n - k + 1))
	else:
		while i <= n - k - 1:
			result += (a[i] + a[-1 - i]) * (i + 1)
			i += 1
		result += sum(a[n - k:k - n]) * (n - k + 1)
		print(result / (n - k + 1))

def main2():
	result = 0
	i = 0
	while i + k <= n:
		result += sum(a[i:i + k])
		i += 1
	print(result / (n - k + 1))
main()


(n, k) = map(int, input().split())
tab = [int(x) for x in input().split()]
tmp = sum(tab[:k])
S = tmp
for i in range(k, len(tab)):
	tmp -= tab[i - k]
	tmp += tab[i]
	S += tmp
print(S / (n - k + 1))


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
(i, j) = (0, 0)
(s, result) = (0, 0)
while j < n:
	s = s + arr[j]
	if j - i + 1 < k:
		j += 1
	elif j - i + 1 == k:
		result += s
		s -= arr[i]
		i += 1
		j += 1
week = n - k + 1
res = result / week
print('%.10f' % res)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
for (i, j) in enumerate(arr):
	if i > 0:
		arr[i] += arr[i - 1]
sum = 0
for i in range(k - 1, n):
	nm = arr[i]
	if i != k - 1:
		nm -= arr[i - k]
	sum += nm
print(sum / (n - k + 1))


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
total = 0
for i in range(n):
	total += arr[i] * min(n - k + 1, min(k, min(i, n - i - 1) + 1))
print('{0:.10f}'.format(total / (n - k + 1)))


arr = list(map(int, input().split()))
N = arr[0]
k = arr[1]
weeks = N - k + 1
i = 1
m = 1
ans = 0
for a in map(int, input().split()):
	ans += a * m
	if i < k:
		m += 1
	if i >= N - k + 1:
		m -= 1
	i += 1
print(ans / weeks)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
A = [0]
for i in l:
	A.append(A[-1] + i)
s = 0
for i in range(k, n + 1):
	s += A[i] - A[i - k]
print(s / (n - k + 1))


(n, k) = map(int, input().split())
ans = 0
a = list(map(int, input().split()))
s = sum(a[:k])
t = s
for i in range(1, 1 + n - k):
	s -= a[i - 1]
	s += a[i + k - 1]
	t += s
print(t / (1 + n - k))


(n, k) = [int(x) for x in input().split()]
y = [0]
l = [int(x) for x in input().split()]
p = k
s = 0
for x in l:
	y.append(y[-1] + x)
ln = len(y)
while k < ln:
	s += y[k] - y[k - p]
	k = k + 1
print(s / (n - p + 1))


def sleep(k, lst):
	sum1 = sum(lst[0:k])
	sum2 = sum1
	for i in range(len(lst) - k):
		sum1 += lst[i + k] - lst[i]
		sum2 += sum1
	return '{:.10f}'.format(sum2 / (len(lst) - k + 1))
(N, K) = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(sleep(K, a))


(n, k) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
sums = 0
for i in range(k):
	sums = sums + A[i]
window = sums
for i in range(0, n - k):
	window = window - A[i] + A[i + k]
	sums += window
weeks = n - k + 1
a = sums / weeks
print('%.11f' % a)


(n, m) = map(int, input().strip().split())
a = input()
b = list(map(float, a.strip().split()))
sum = 0
t = m
for i in range(m):
	sum += b[i]
temp = sum
L = 0
while m < n:
	temp = temp - b[L] + b[m]
	L += 1
	m += 1
	sum += temp
ans = sum / (n - t + 1)
print('%.10f' % ans)


ar = {}
(a, b) = input().split()
ar = input().split()
a = int(a)
b = int(b)
for i in range(0, a):
	ar[i] = int(ar[i])
r = 0
s = 0
for i in range(0, b):
	s = s + ar[i]
r = s
for i in range(0, a - b):
	s = s - ar[i] + ar[b + i]
	r = r + s
print(r / (a - b + 1))


import math
(n, k) = map(int, input().split())
arr = [int(z) for z in input().split()]
if n == k:
	print(f'{sum(arr):.6f}')
	exit()
res = 0
if k > math.ceil(n / 2):
	for i in range(n - k + 1):
		res += arr[i] * (i + 1)
	for i in range(n - k + 1, n - k + 1 + (2 * k - n) - 1):
		res += arr[i] * (n - k + 1)
	for i in range(n - k + 1 + (2 * k - n) - 1, n):
		res += arr[i] * (n - i)
else:
	for i in range(k - 1):
		res += arr[i] * (i + 1)
		res += arr[-(i + 1)] * (i + 1)
	for i in range(k - 1, n - k + 1):
		res += arr[i] * k
print(res / (n - k + 1))


(n, m) = map(int, input().split())
su = 0
su1 = 0
l = list(map(int, input().split()))
for i in range(min(n, m)):
	su += l[i]
	su1 = su
j = 0
for i in range(min(n, m), n):
	su += l[i] - l[j]
	j += 1
	su1 += su
print(su1 / (j + 1))


def computeAvg(n, k, a, ans=0.0):
	for i in range(n):
		ans += float(min(k, n - k + 1, n - i, i + 1)) * a[i]
	return ans / (n - k + 1)
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
print('%.8f' % computeAvg(n, k, a))


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
res = 0
t = n - k
res = sum(s) * (n - k + 1)
i = 0
while t:
	res -= t * (s[i] + s[-i - 1])
	t -= 1
	i += 1
print(res / (n - k + 1))


(n, k) = map(int, input().split())
arr = list(map(float, input().split()))
sum_arr = 0
for i in range(n):
	sum_arr += arr[i] * min(n - k + 1, k, i + 1, n - i)
print(sum_arr / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n):
	l = max(0, i - k + 1)
	r = min(i, n - k)
	s += a[i] * (r - l + 1)
print(s / (n - k + 1))


(n, k) = map(int, input().split(' '))
num = list(map(int, input().split(' ')))
ans = 0
pre = 0
n = len(num)
num.insert(0, 0)
for i in range(1, n + 1):
	pre += num[i]
	if i >= k:
		pre -= num[i - k]
		ans += pre
print(ans / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
z = n - k + 1
for i in range(n):
	s += a[i] * min(z, k, i + 1, n - i)
print(s / z)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		l = max(i - k + 1, 0)
		r = min(i, n - k)
		ans += a[i] * (r - l + 1)
	print('{:.12f}'.format(ans / (n - k + 1)))
main()


s = input().split()
n = int(s[0])
k = int(s[1])
s = input().split()
list = []
for i in range(0, n):
	list.append(int(s[i]))
s = sum(list[0:k])
res = s
for i in range(k, n):
	s -= list[i - k]
	s += list[i]
	res += s
res /= n - k + 1
print(res)


(n, k) = (int(x) for x in input().split())
s = [int(x) for x in input().split()]
a = 0
for i in range(k):
	a += s[i]
a /= k
x = a
if n == k:
	print(a * k)
else:
	for i in range(n - k):
		x = (x * k + s[i + k] - s[i]) / k
		a += x
	a /= n - k + 1
	print(a * k)


def sleep(n, k, a):
	week = 0
	count = 1
	b = k
	s = n - k + 1
	if n - k + 1 > b:
		b = n - k + 1
		s = k
	for i in range(b):
		if i + 1 < s:
			week += (a[i] + a[~i]) * (i + 1)
			count += 1
		elif s <= i + 1:
			week += a[i] * count
	week = week / (n - k + 1)
	return week
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
print(sleep(n, k, a))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sum = 0
for i in range(k):
	sum += a[i]
total = sum
i = 1
while i + k - 1 < n:
	sum -= a[i - 1]
	sum += a[i + k - 1]
	i += 1
	total += sum
print(format(total / (n - k + 1), '.6f'))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
tmp = sum(a[:k])
i = k
s = tmp
while i < n:
	tmp += a[i] - a[i - k]
	s += tmp
	i += 1
print(s / (n - k + 1))


import sys
import os
import math
(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
if n == k:
	print(sum(A))
elif n - k >= k:
	v = 0
	for i in range(n):
		if i < k:
			v += (i + 1) * A[i]
		elif n - k < i:
			v += (n - i) * A[i]
		else:
			v += k * A[i]
	ans = v / (n - k + 1)
	print(ans)
else:
	v = 0
	for i in range(n):
		if i < n - k:
			v += (i + 1) * A[i]
		elif k <= i:
			v += (n - i) * A[i]
		else:
			v += (n - k + 1) * A[i]
	ans = v / (n - k + 1)
	print(ans)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
r = 0
for i in range(k):
	r = r + s[i]
t = r
for i in range(k, n):
	r = r - s[i - k]
	r = r + s[i]
	t = t + r
print(t / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
s = 0
for x in range(n):
	s += a[x]
	b[x + 1] = s
s = 0
for y in range(n - k + 1):
	s += b[y + k] - b[y]
print(s / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
tmp = a[0]
i = 0
j = 0
an = 0
for s in a:
	i += 1
	if i < k + 1:
		an += s
	else:
		ans += an
		j += 1
		an -= tmp
		an += s
		tmp = a[j]
ans += an
print(ans / (n - k + 1))


import sys, math
Tests = 1
for _ in range(Tests):
	(n, k) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	arr = [0] + arr
	ans = 0
	for i in range(1, n + 1):
		b = min(n - k + 1, i)
		a = max(i - k + 1, 1)
		if a <= b:
			ans += arr[i] * (b - a + 1)
	print(ans / (n - k + 1))


(n, k) = list(map(int, input().split(' ')))
li = list(map(int, input().split(' ')))
sum = 0
for x in range(k):
	sum = sum + li[x]
i = 0
j = k
res = sum
for x in range(n - k):
	sum = sum - li[i] + li[j]
	res = res + sum
	i += 1
	j += 1
print(res / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a[:k])
ans = total
for i in range(k, n):
	total += a[i]
	total -= a[i - k]
	ans += total
print(ans / (n - k + 1))


(n, k) = [int(p) for p in input().split()]
w = n - k + 1
arr = [int(p) for p in input().split()]
s = sum(arr[:k])
curr = s
j = k
i = 0
while j < len(arr):
	s -= arr[i]
	i += 1
	s += arr[j]
	j += 1
	curr += s
print(curr / w)


(n, k) = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
c = 0
if n == 1:
	print(lst[0])
elif n == k:
	print(sum(lst) / (n - k + 1))
else:
	c = [sum(lst[:k])]
	s = c[0]
	i = 0
	j = k
	while j < n:
		s += lst[j]
		s -= lst[i]
		c.append(s)
		i += 1
		j += 1
	print(sum(c) / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
slide = a[:k]
current = sum(slide)
ans = current
for x in range(1, n - k + 1):
	current = current - a[x - 1] + a[x + k - 1]
	ans += current
print('{0:.6f}'.format(ans / (n - k + 1)))


from math import floor

def bounded_sum(l, p1, p2):
	r = 0
	for i in range(p1, p2 + 1):
		r += l[i]
	return r

def solve(n, k, a):
	r = 0
	for i in range(k):
		r += a[i]
	aux = r
	for j in range(k, n):
		r += a[j] - a[j - k]
		aux += r
	return aux / (n - k + 1)
(N, K) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print('{0:.12f}'.format(solve(N, K, A)))


(n, k) = list(map(int, input().split()))
v = []
a = list(map(int, input().split()))
s = 0
for i in range(n):
	s += a[i]
	v.append(s)
ans = 0
for j in range(k - 1, n):
	if j == k - 1:
		ans += v[j]
	else:
		ans += v[j] - v[j - k]
print(ans / (n - k + 1))


def luckyYear():
	n = int(input())
	original = n
	p = -1
	f = 0
	while n > 0:
		f = n % 10
		n //= 10
		p += 1
	f += 1
	f *= 10 ** p
	print(f - original)

def averageSleepTime():
	(n, k) = map(int, input().split())
	sleep = list(map(int, input().split()))
	run = 0
	for i in range(k):
		run += sleep[i]
	runavg = [run]
	for i in range(k, n):
		run = run - sleep[i - k] + sleep[i]
		runavg.append(run)
	print('{:.10f}'.format(sum(runavg) / (n - k + 1)))
averageSleepTime()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
total = 0
week = 0
for i in range(0, k):
	week += a[i]
total += week
for i in range(1, n - k + 1):
	week -= a[i - 1]
	week += a[i + k - 1]
	total += week
print(total / (n - k + 1))


(n, k) = map(int, input().split())
s = [0]
summa = 0
A = list(map(int, input().split()))
for i in range(n):
	s.append(s[i] + A[i])
for i in range(k, n + 1):
	summa += s[i] - s[i - k]
from decimal import Decimal as D
ans = D(summa) / D(n - k + 1)
print(ans)


u = input()
x = u.split()
n = int(x[0])
k = int(x[1])
sum2 = 0
add = 0
arr = []
arr2 = []
t = input()
x = t.split()
for i in range(0, n):
	arr.append(int(x[i]))
	sum2 += arr[i]
	arr2.append(sum2)
for i in range(k, n):
	add += arr2[i] - arr2[i - k]
add += arr2[k - 1]
l = n - k + 1
ans = add / float(l)
print(ans)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
ans = 0
niche = n - k + 1
presum = [0] * n
presum[0] = a[0]
for i in range(1, n):
	presum[i] = presum[i - 1] + a[i]
for i in range(k):
	ans += a[i]
j = 0
for i in range(k, n):
	ans += presum[i] - presum[j]
	j += 1
print(ans / niche)


import sys, math, queue
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
s = sum(a[:k - 1])
for i in range(k - 1, n):
	s += a[i]
	ans += s
	s -= a[i - k + 1]
print(ans / (n - k + 1))


(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
summa = sum(nums[:k])
sums = [summa]
for i in range(k, n):
	summa = summa - nums[i - k] + nums[i]
	sums.append(summa)
print(sum(sums) / (n - k + 1))


(n, k) = map(int, input().split())
al = list(map(int, input().split()))
res = 0
for i in range(n):
	res += al[i] * min(k, i + 1, n - i, n - k + 1) / 1.0 / (n - k + 1)
print(res)


def addion(arr_ai, k):
	output = 0
	prevOut = 0
	answer = 0
	for x in range(0, len(arr_ai)):
		if x + k <= len(arr_ai):
			if prevOut == 0:
				answer = int(arr_ai[x])
				if k > 1:
					for z in range(1, k):
						answer += int(arr_ai[x + z])
			elif k > 1:
				answer = prevOut - int(arr_ai[x - 1]) + int(arr_ai[x + k - 1])
			else:
				answer = int(arr_ai[x])
			output += answer
			prevOut = answer
	return output
n_k = input()
a_i = input()
nk_arr = n_k.split(' ')
n = int(nk_arr[0])
k = int(nk_arr[1])
w = float(n) - float(k) + 1
if n == 1:
	print(a_i)
else:
	ai_arr = a_i.split(' ')
	sum = addion(ai_arr, int(k))
	output = round(sum / w, 6)
	print(output)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
movSum = sum(a[0:k])
tot = movSum
for i in range(1, n - k + 1):
	movSum -= a[i - 1]
	movSum += a[i + k - 1]
	tot += movSum
print(tot / (n - k + 1))


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []

def hnbhai(tc):
	(n, k) = sd()
	a = sd()
	w = n - k + 1
	s = sum(a[:k])
	tot = s
	for i in range(k, n):
		s -= a[i - k]
		s += a[i]
		tot += s
	print(tot / w)
for _ in range(1):
	hnbhai(_ + 1)


import sys
sys.setrecursionlimit(10000)
t = 1
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ans = 0
	for i in range(k):
		ans += a[i]
	thesum = ans
	for j in range(k, n):
		thesum -= a[j - k]
		thesum += a[j]
		ans += thesum
	print(ans / (n - k + 1))


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
	c = min(i + 1, K)
	c -= K - min(N - i, K)
	ans += c * A[i]
print('%.7f' % (ans / (N - K + 1)))


desc = input().split()
num = int(desc[0])
days = int(desc[1])
sleep = input().split()
sleepsum = 0
for i in range(num):
	count = min(i + 1, num - i)
	count = min(count, num - days + 1)
	count = min(count, days)
	sleepsum += count * int(sleep[i])
print(sleepsum / (num - days + 1))


(a, b) = map(int, input().split())
x = list(map(int, input().split()))
y = [a - b + 1] * a
z = list(range(1, a + 1))
w = z[::-1]
c = []
for i in range(a):
	c.append(min(y[i], z[i], w[i], b))
s = 0
for i in range(a):
	s += c[i] * x[i]
print(s / (a - b + 1))


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
k_sum = sum(a[:k])
tot = k_sum
(left, right) = (0, k)
while right < n:
	k_sum -= a[left]
	k_sum += a[right]
	tot += k_sum
	left += 1
	right += 1
print(tot / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pref = [0]
for i in a:
	pref.append(i + pref[-1])
cnt = 0
cur = 0
for i in range(k, n + 1):
	cnt += 1
	cur += pref[i] - pref[i - k]
print(cur / cnt)


import sys

def solve():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	cons = sum(a[:k])
	tot = cons
	for i in range(k, n):
		cons += a[i] - a[i - k]
		tot += cons
	ans = tot / (n - k + 1)
	print(ans)
solve()


import itertools
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
w = sum(itertools.islice(a, 0, k))
s = w
for i in range(n - k):
	w = w - a[i] + a[i + k]
	s += w
print(s / (n - k + 1))


(n, k) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
total = 0
k2 = 1
a = k - 1
b = n - k + 1
for i in range(a):
	total += (i + 1) * x[i]
	k2 = i + 2
	if i + k == n:
		k2 = i + 1
		a = k2
		b = n - a + 1
		break
for i in range(a, b, 1):
	total += k2 * x[i]
k3 = k2 - 1
for i in range(b, n, 1):
	total += k3 * x[i]
	k3 -= 1
total /= n - k + 1
print(total)


(n, k) = map(int, input().split())
valores = list(map(int, input().split()))
v_acumu = [0 for i in range(len(valores))]
v_acumu[0] = valores[0]
for i in range(len(valores)):
	if i == 0:
		continue
	v_acumu[i] = valores[i] + v_acumu[i - 1]
v_acumu = [0] + v_acumu
somatorio = 0
for i in range(n):
	if i + k > n:
		break
	somatorio += v_acumu[i + k] - v_acumu[i]
print(somatorio / (n - k + 1))


f = lambda : map(int, input().split())
(n, k) = f()
t = [0] + list(f())
for i in range(n):
	t[i + 1] += t[i]
m = min(n - k + 1, k)
print((sum(t[m:]) - sum(t[:-m])) / (n - k + 1))


(n, k) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = s[i] + a[i]
t = 0
for i in range(k, n + 1):
	t += s[i] - s[i - k]
print(t / (n - k + 1))


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
for i in range(n):
	if i < k - 1:
		c += l[i] * min(n - k + 1, i + 1)
	elif i + k - 1 >= n:
		c += l[i] * min(n - k + 1, n - i)
	else:
		c += min(k, n - k + 1) * l[i]
print(c / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
summ = 0
multi = 1
for i in range(n):
	if n - i > k and multi < k:
		summ += a[i] * multi
		multi += 1
	elif n - i > k or i + 1 < k:
		summ += a[i] * multi
	elif n - i <= k:
		summ += a[i] * multi
		multi -= 1
print(summ / (n - k + 1))


from sys import stdin, stdout
from decimal import Decimal
(n, k) = map(int, stdin.readline().split())
values = list(map(Decimal, stdin.readline().split()))
cnt = [values[0]]
for i in range(1, n):
	cnt.append(cnt[-1] + values[i])
cnt.append(0)
ans = 0
for i in range(k - 1, n):
	ans += cnt[i] - cnt[i - k]
stdout.write(str(ans / Decimal(n - k + 1)))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A[:k])
oper = S
for i in range(n - k):
	oper -= A[i]
	oper += A[i + k]
	S += oper
print(S / (n - k + 1))


(n, k) = map(int, input().split())
res = 0
a = [int(i) for i in input().split()]
cur_sum = sum(a[0:k])
res += cur_sum
for i in range(n - k):
	cur_sum -= a[i]
	cur_sum += a[k + i]
	res += cur_sum
print(res / (n - k + 1))


from fractions import gcd
from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
MOD = 10 ** 9 + 7

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		exit()
	elif n == k:
		print(sum(a))
		exit()
	ans = 0
	su = 0
	for i in range(k - 1):
		su += a[i]
	for i in range(k - 1, n):
		su += a[i]
		ans += su
		su -= a[i - k + 1]
	print(ans / (n - k + 1))
main()


import sys
from itertools import accumulate
(n, k) = map(int, input().split())
a = [0] + list(accumulate(map(int, input().split())))
total = 0
for (l, r) in zip(range(n), range(k, n + 1)):
	total += a[r] - a[l]
print(total / (n - k + 1))


(n, k) = map(int, input().split())
arr = list(map(float, input().split()))
sm = avr = sum(arr[:k])
for i in range(k, n):
	sm += arr[i] - arr[i - k]
	avr += sm
print(avr / (n - k + 1))


(n, k) = [int(x) for x in input().split()]
a = [0] + [int(x) for x in input().split()]
for i in range(n):
	a[i + 1] += a[i]
print(sum([a[i] - a[i - k] for i in range(k, n + 1)]) / (n - k + 1))


import math
(n, k) = input().split(' ')
n = int(n)
k = int(k)
count = n - k + 1
a_array = input().split(' ')
summ = 0
if k > count:
	k = count
if k > n / 2:
	k = math.ceil(n / 2)
for i in range(k - 1):
	summ += int(a_array[i]) * (i + 1)
	summ += int(a_array[-i - 1]) * (i + 1)
for i in range(k - 1, n - k + 1):
	summ += int(a_array[i]) * k
print(summ / count)


(m, n) = map(int, input().split())
arr = [int(x) for x in input().split()]
s = sum(arr[:n])
val = m - n + 1
ns = s / val
for i in range(n, m):
	s = s + arr[i] - arr[i - n]
	ns += s / val
print(ns)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
total = 0
for (i, el) in enumerate(a):
	factor = k
	factor = min([k, i + 1, n - k + 1, n - 1 - i + 1])
	total += factor * el
print(total / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = x = sum(a[:k])
for i in range(k, n):
	s += a[i] - a[i - k]
	x += s
print(x / (n - k + 1))


s = input()
l = s.split()
n = int(l[0])
k = int(l[1])
l[0] = 0
s = input()
l = s.split()
l = [0] + l
for i in range(1, n + 1):
	l[i] = l[i - 1] + int(l[i])
sum = 0
for i in range(k, n + 1):
	sum += l[i] - l[i - k]
print('{:.10f}\n'.format(sum / (n - k + 1)))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = []
c = 0
for i in range(n):
	c = c + l[i]
	d.append(c)
s = d[k - 1]
for i in range(k, n):
	s = s + d[i] - d[i - k]
x = n - k + 1
print(s / x)


while True:
	try:
		(n, k) = map(int, input().split())
		a = input().split()
		sum = []
		sum.append(0)
		for i in range(1, n + 1):
			sum.append(int(a[i - 1]) + int(sum[i - 1]))
		tmp = n - k + 1
		s = 0
		for i in range(tmp, n + 1):
			s += sum[i] - sum[i - tmp]
		print('%.10f' % (s * 1.0 / tmp))
	except EOFError:
		break


(n, k) = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
initsum = sum(a[:k])
allsum = initsum
for i in range(k, n):
	initsum -= a[i - k]
	initsum += a[i]
	allsum += initsum
print(allsum / (n - k + 1))


def main():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	start = sum(arr[:k])
	s = start
	for i in range(n - k):
		start -= arr[i]
		start += arr[k + i]
		s += start
	print(s / (n - k + 1))
main()


from itertools import *

def calc_pref(l):
	n = len(l)
	res = list(repeat(0, n + 1))
	for i in range(1, n + 1):
		res[i] += res[i - 1] + l[i - 1]
	return res
[n, k] = map(int, input().split())
l = list(map(int, input().split()))
pref = calc_pref(l)
res = 0.0
for i in range(0, n - k + 1):
	res += (pref[i + k] - pref[i]) / (n - k + 1)
print(res)


arr = list(map(int, input().split()))
n = arr[0]
k = arr[1]
a = list(map(int, input().split()))
ts = 0
for i in range(k):
	ts += a[i]
i = 1
j = k
s = ts
while j < n:
	ts -= a[i - 1]
	ts += a[j]
	s += ts
	i += 1
	j += 1
print(s / (n - k + 1))


(n, k) = (int(i) for i in input().split())
arr = [int(i) for i in input().split()]
s = 0
j = 1
t = n - k + 1
if k > n / 2:
	k = n - k + 1
for i in range(n):
	s += j * arr[i]
	if i < k - 1:
		j += 1
	elif i >= n - k:
		j -= 1
print('%.12f' % float(s / t))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
acc = sum(arr[0:k])
sleep = acc
for i in range(k, n):
	acc += arr[i]
	acc -= arr[i - k]
	sleep += acc
print(sleep / (n - k + 1))


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
sm = 0
ar = list(map(int, input().split()))
cr = sum(ar[:k - 1])
for x in range(n - k + 1):
	cr += ar[k + x - 1]
	sm += cr
	cr -= ar[x]
print(sm / (n - k + 1))


def solve(n, k, a):
	s = sum(a[:k])
	tot = 0
	l = 0
	tot += s
	for r in range(k, n):
		s = s - a[l] + a[r]
		tot += s
		l += 1
	return tot / (n - k + 1)

def main():
	(n, k) = map(int, input().split(' '))
	a = [int(x) for x in input().split(' ')]
	print('{:0.6f}'.format(solve(n, k, a)))
main()


import math
l = input()
g = (token for token in l.split())
for i in g:
	n = int(i)
	break
for i in g:
	k = int(i)
	break
a = []
r = float(0)
l = input()
g = (token for token in l.split())
for i in g:
	a.append(float(i))
	if i == n - 1:
		break
lim = min(k, n - k + 1)
for i in range(lim):
	r += a[i] * (i + 1)
	if i < n - i - 1:
		r += a[n - i - 1] * (i + 1)
for i in range(lim, n - lim):
	r += a[i] * lim
if not n == 1:
	r /= n - k + 1
print(r)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))

def get_t(i):
	start = max(i - k + 1, 0)
	end = min(i + k - 1, n - 1) - (k - 1)
	if start > end:
		return 0
	return end - start + 1
s = 0
for i in range(n):
	s += get_t(i) * l[i]
print(s / (n - k + 1))


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = [0]
for i in range(n):
	b.append(b[-1] + a[i])
weeks = n - k + 1
sum = 0
for i in range(weeks):
	sum += b[i + k] - b[i]
print('{:.10f}'.format(sum / weeks))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
ww = n - k + 1
a = []
a.append(0)
for i in range(n):
	a.append(arr[i])
for i in range(1, n + 1):
	a[i] = a[i] + a[i - 1]
ans = 0
for i in range(k, n + 1):
	tmp = a[i] - a[i - k]
	ans += tmp / ww
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
su = sum(a[:k])
s = su
j = k
while j < n:
	s = s + a[j] - a[j - k]
	su += s
	j += 1
print(su / (n - k + 1))


from sys import stdin
(a, b) = map(int, stdin.readline().split())
c = list(map(int, stdin.readline().split()))
s = sum(c[:b])
k = s
for i in range(1, a - b + 1):
	k = k - c[i - 1] + c[i + b - 1]
	s += k
print(s / (a - b + 1))


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		(n, k) = [int(x) for x in R().split()]
		a = [0] + [int(x) for x in R().split()]
		total = 0.0
		for j in range(1, n + 1):
			total += min(k, n - k + 1, j, n - j + 1) * a[j]
		avg = total / (n - k + 1)
		W('%.15lf\n' % avg)
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
m = min(k, n - k + 1)
s = 0
for i in range(1, m):
	s += i * a[i - 1]
for i in range(m, n - m + 2):
	s += m * a[i - 1]
for i in range(1, m):
	s += i * a[n - i]
print(s / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
rec = [0]
for i in range(len(a)):
	rec.append(rec[-1] + a[i])
for i in range(n - k + 1):
	s += rec[i + k] - rec[i]
print(s / (n - k + 1))


class CodeforcesTask808BSolution:

	def __init__(self):
		self.result = ''
		self.n_k = []
		self.records = []

	def read_input(self):
		self.n_k = [int(x) for x in input().split(' ')]
		self.records = [int(x) for x in input().split(' ')]

	def process_task(self):
		ss = sum(self.records[:self.n_k[1]])
		avs = ss
		for x in range(self.n_k[0] - self.n_k[1]):
			ss += self.records[self.n_k[1] + x] - self.records[x]
			avs += ss
		self.result = str(avs / (self.n_k[0] - self.n_k[1] + 1))

	def get_result(self):
		return self.result
Solution = CodeforcesTask808BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


while True:
	try:
		(n, k) = map(int, input().split(' '))
	except:
		break
	L = [int(x) for x in input().split(' ')]
	ans = sum = 0.0
	for x in L[:k]:
		sum += x
	ans += sum
	for i in range(k, n):
		sum = sum - L[i - k] + L[i]
		ans += sum
	print('%.10f' % (ans / (n - k + 1)))


(n, k) = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
tot = 0
for i in range(len(L)):
	j = min(n - i, i + 1, k, n - k + 1)
	tot += j * L[i]
tota = '{0:.10f}'.format(tot / (n - k + 1))
print(tota)


import sys, math
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	tab = list(map(int, input().split()))
	s = 0
	cu = [0]
	for x in range(n):
		s += tab[x]
		cu.append(s)
	s = 0
	for x in range(n - k + 1):
		if x + k <= n:
			s += cu[x + k] - cu[x]
	print(s / (n - k + 1))
main()


[n, k] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
s = sum((min(i + 1, k, n - k + 1, n - i) * a for (i, a) in enumerate(ais)))
print(s / (n - k + 1))


nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
days = [int(x) for x in input().split()]
prev_summ = 0
total_weeks = n - k + 1
for i in range(0, k):
	prev_summ += days[i]
avg = prev_summ / total_weeks
ind = k
still_weeks = n - k
while still_weeks:
	prev_summ -= days[ind - k]
	prev_summ += days[ind]
	copy_sum = prev_summ
	copy_sum /= total_weeks
	avg += copy_sum
	still_weeks -= 1
	ind += 1
print('%.10f' % avg)


def solve():
	(n, k) = map(int, input().split())
	a = [0] + list(map(int, input().split()))
	for i in range(1, n + 1):
		a[i] = a[i - 1] + a[i]
	ans = 0.0
	for i in range(k, n + 1):
		ans += (a[i] - a[i - k]) / (n - k + 1)
	print(ans)
solve()


(n, k) = map(int, input().split())
arr = list(map(float, input().split()))
sm = sum(arr[:k])
avr = sm
i = k
while i < n:
	sm -= arr[i - k]
	sm += arr[i]
	avr += sm
	i += 1
print(avr / (n - k + 1))


(n, k) = map(int, input().split())
aa = list(map(int, input().split()))
(res, t) = (sum(aa) * k, 0)
for (a, b) in zip(aa[:k - 1], aa[-1:-k:-1]):
	t += a + b
	res -= t
print(res / (n - k + 1))


l = input().split()
(n, k) = (int(l[0]), int(l[1]))
(arr, s) = (input().split(), 0)
for i in range(len(arr)):
	s += int(arr[i]) * (min(i, n - k) - max(i - k + 1, 0) + 1)
print(s / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
start = min(k - 1, n - k)
count = sum(a[start:n - start]) * (start + 1)
for i in range(start):
	count += (a[i] + a[~i]) * (i + 1)
print(count / (n - k + 1))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
running_sum = []
acc = 0
for i in range(0, k):
	acc += a[i]
	running_sum.append(acc)
total = running_sum[k - 1]
for i in range(k, n):
	acc += a[i]
	running_sum.append(acc)
	total += running_sum[i] - running_sum[i - k]
print('%.10f' % (total / (n - k + 1)))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
N = n - k + 1
S = 0
for i in range(k):
	S += A[i]
V = S
for i in range(k, len(A)):
	S = S + A[i] - A[i - k]
	V += S
x = V / N
if x * 10 ** 6 % 1 == 0:
	print(str(x) + str('000000'))
else:
	print(x)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
t = n - k + 1
i = 1
summ = 0
if k > n / 2:
	k = n - k + 1
for j in range(n):
	summ += i * a[j]
	if j < k - 1:
		i += 1
	elif j >= n - k:
		i -= 1
print('%.10f' % float(summ / t))


from sys import stdin
inp = stdin.readline
(n, k) = map(int, inp().split())
a = list(map(int, inp().split()))
cur_sum = 0
for i in range(k):
	cur_sum += a[i]
total_sum = cur_sum
for i in range(k, n):
	cur_sum += a[i]
	cur_sum -= a[i - k]
	total_sum += cur_sum
print('{:.6f}'.format(total_sum / (n - k + 1)))


param = input()
(n, k) = map(int, param.split(' '))
raw_data = input()
data = list(map(int, raw_data.split(' ')))
result = 0
top = n - k + 1 if n - k < k else k
for (i, item) in enumerate(data, start=1):
	if i < top:
		result += item * i
	elif i >= top and i <= n - top + 1:
		result += item * top
	else:
		result += item * (n + 1 - i)
result /= n - k + 1
print('{0:.6f}'.format(result))


import collections as cc
import bisect as bi
I = lambda : list(map(int, input().split()))
(n, k) = I()
ar = I()
total = n - k + 1
curr = sum(ar[:k])
ans = [curr]
for i in range(k, n):
	curr += ar[i]
	curr -= ar[i - k]
	ans.append(curr)
print(sum(ans) / total)


x = input()
(a, b) = x.split()
n = int(a)
k = int(b)
x = input()
x = x.split()
for i in range(0, n):
	x[i] = int(x[i])
ans = 0
(l, r) = (0, n - 1)
tim = 1
mon = n - k + 1
while l <= r:
	if l == r:
		ans += x[l] * tim
		break
	else:
		ans += (x[l] + x[r]) * tim
	l += 1
	r -= 1
	if tim < min(mon, k):
		tim += 1
print(ans / mon)


(n, k) = input().split()
n = int(n)
k = int(k)
arr = [0] * n
arr = input().split()
for i in range(n):
	arr[i] = int(arr[i])
length = n - k + 1
window = sum(arr[:n - k + 1])
total = window
for t in range(1, k, +1):
	window = window - arr[t - 1] + arr[t + (n - k)]
	total = total + window
print(total / (n - k + 1))


(n, k) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
sup = 0
for i in range(1, n + 1):
	sup += min(n - k + 1, k, i, n - i + 1) * a[i - 1]
sup /= n - k + 1.0
print(sup)


from collections import deque
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
d = deque()
su = 0
cur = 0
i = 0
while i < k:
	cur += lis[i]
	d.append(lis[i])
	i += 1
while i < n:
	su += cur
	cur -= d.popleft()
	d.append(lis[i])
	cur += lis[i]
	i += 1
su += cur
print(su / (n - k + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pref = [0 for i in range(n - k + 1)]
pref[0] = sum(a[:k])
for i in range(1, n - k + 1):
	pref[i] = pref[i - 1] - a[i - 1] + a[i + k - 1]
print(sum(pref) / (n - k + 1))


import sys
from itertools import accumulate

def solve():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ac = [0] + list(accumulate(a))
	ans = sum((ac[k + i] - ac[i] for i in range(n - k + 1)))
	ans = ans / (n - k + 1)
	print(ans)
solve()


import sys
from bisect import bisect_left as lb
from collections import deque
from queue import PriorityQueue as pq
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
(n, k) = il()
a = il()
s = 0
s1 = 0
t = 0
for i in range(k):
	s += a[i]
s1 += s
t += 1
for i in range(k, n):
	s -= a[i - k]
	s += a[i]
	s1 += s
	t += 1
print(s1 / t)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pref = [0]
for i in a:
	pref.append(i + pref[-1])
d = sm = 0
for i in range(k, n + 1):
	sm += pref[i] - pref[i - k]
	d += 1
print(sm / d)


from sys import stdin, stdout
(n, k) = [int(i) for i in stdin.readline().split()]
a = [int(i) for i in stdin.readline().split()]
sm = [0] * (n + 1)
sm[1] = a[0]
for i in range(2, n + 1):
	sm[i] = sm[i - 1] + a[i - 1]
ans = c = 0
for i in range(n - k + 1):
	c += 1
	ans += sm[i + k] - sm[i]
stdout.write(str(ans / c))


from sys import stdin
input = stdin.readline
T = 1
for t in range(1, T + 1):
	(n, k) = map(int, input().split())
	_input = list(map(int, input().split()))
	if n == 1:
		print('{0:.6f}'.format(sum(_input) / (n - k + 1)))
		exit()
	for i in range(len(_input)):
		if i > 0:
			_input[i] += _input[i - 1]
	_sum = 0
	for i in range(k - 1, len(_input)):
		if i == k - 1:
			_sum += _input[i]
		else:
			_sum += _input[i] - _input[i - k]
	print('{0:.6f}'.format(_sum / (n - k + 1)))


(n, k) = list(map(int, input().split()))
c = []
a = list(map(int, input().split()))
sum = 0
for i in range(n):
	sum += a[i]
	c.append(sum)
ans = 0
for j in range(k - 1, n):
	if j == k - 1:
		ans += c[j]
	else:
		ans += c[j] - c[j - k]
print(ans / (n - k + 1))


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a[:k])
res = total
for i in range(1, n - k + 1):
	total += -a[i - 1] + a[i + k - 1]
	res += total
print(res / (n - k + 1))


(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
sumans = sum(l[:m])
temp = sumans
j = m
for i in range(1, n - m + 1):
	temp += l[j]
	temp -= l[i - 1]
	sumans += temp
	j += 1
print(sumans / (n - m + 1))


t = list(map(int, input().split()))
n = t[0]
k = t[1]
a = list(map(int, input().split()))
summa = sum(a[0:k])
res = summa
for i in range(n - k):
	summa -= a[i]
	summa += a[k + i]
	res += summa
print('%6f' % (res / (n - k + 1)))


(n, k) = map(int, input().split())
values = list(map(int, input().split()))
total = sum(values[:k])
hours = total
for i in range(k, n):
	total += values[i] - values[i - k]
	hours += total
print('%.6f' % (hours / (n - k + 1)))


a = input().split()
n = int(a[0])
k = int(a[1])
v = list(map(int, input().split()))
s = 0
co = 1
cur_s = 0
cur = 0
dal = k - 1
for i in range(k):
	cur_s += v[i]
s += cur_s
while dal + 1 < n:
	co += 1
	cur_s -= v[cur]
	cur += 1
	dal += 1
	cur_s += v[dal]
	s += cur_s
print(s / co)


(n, k) = map(int, input().split())
K = min(k, n - k + 1)
a = list(map(int, input().split()))
ret = 0
for (i, ai) in enumerate(a):
	ret += ai * min(K, i + 1, n - i)
print(ret / (n - k + 1))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
pre = [l[0]]
for i in range(1, n):
	pre.append(l[i] + pre[i - 1])
sums = pre[k - 1]
for i in range(1, n - k + 1):
	sums += pre[k + i - 1] - pre[i - 1]
print(sums / (n - k + 1))


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
l = il()
sm = sum(l[:k])
asm = sm
for i in range(k, n):
	sm -= l[i - k]
	sm += l[i]
	asm += sm
print(asm / (n - k + 1))


(p, w) = map(int, input().split())
g = 0
s = list(map(int, input().split()))
q = len(s)
o = min(q - w + 1, w)
if q == w:
	print(sum(s))
	exit()
for i in range(q // 2):
	g += s[i] * min(i + 1, o)
s.reverse()
t = 1 if q % 2 else 0
for i in range(q // 2 + t):
	g += s[i] * min(i + 1, o)
print(round(g / (q - w + 1), 6))


(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
list1 = list(map(int, input().strip().split(' ')))
s = sum(list1[0:k])
s1 = s
for i in range(n - k):
	s = s + (list1[i + k] - list1[i])
	s1 += s
print(s1 / (n - k + 1))


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
sm = sum(l[0:k])
tot = 0
tot += sm
for i in range(k, n):
	sm += l[i]
	sm -= l[i - k]
	tot += sm
print(tot / (n - k + 1))


(dienu_sk, ned_len) = [int(x) for x in input().split()]
ned_sk = dienu_sk - ned_len + 1
arr = [int(x) for x in input().split()]
summa = 0
cur_summa = 0
for i in range(ned_len):
	cur_summa += arr[i]
summa = cur_summa
prev = 0
next = ned_len
while next < dienu_sk:
	cur_summa -= arr[prev]
	cur_summa += arr[next]
	summa += cur_summa
	prev += 1
	next += 1
rez = summa / ned_sk
print('%.6f' % rez)


(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = [0] * len(l1)
for i in range(len(l1)):
	l2[i] = l1[i]
for i in range(1, len(l1)):
	l2[i] += l2[i - 1]
s = 0
for i in range(k - 1, len(l1)):
	x = l2[i]
	if i - k >= 0:
		x -= l2[i - k]
	s += x
print(s / (n - k + 1))


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def check(n):
	n = list(set(list(str(n))))
	if len(n) == 1:
		return True
	n.sort()
	if n[0] == '0':
		if len(n) <= 2:
			return True
		else:
			return False
	else:
		return False
(n, k) = M()
l = L()
x = 0
ans = sum(l[:k])
x = ans
for i in range(k, n):
	x += l[i]
	x -= l[i - k]
	ans += x
print(ans / (n - k + 1))


import math as m

def lmap():
	return list(map(int, input().split()))

def mmap():
	return map(int, input().split())
(n, k) = mmap()
div = n - k + 1
w = lmap()
summ = sum(w)
if k == 1:
	ans = summ / div
	print('%.10f' % ans)
else:
	if k * 2 > n:
		k = n % k + 1
	(su, mul) = (0, 0)
	for i in range(n):
		if i < k - 1:
			mul += 1
			su += w[i] * mul
		elif i > n - k:
			mul -= 1
			su += w[i] * mul
		else:
			mul = k
			su += w[i] * mul
	ans = su / div
	print('%.10f' % ans)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
s = 0
for i in range(n - k + 1):
	s += a[i] * min(i + 1, k)
for i in range(n - k + 1, n):
	s += a[i] * min(n - k + 1, n - i)
s /= n - k + 1
print('%.7f' % s)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
if n == 1:
	print(a[0])
elif n == 2:
	print((a[0] + a[1]) / (n - k + 1))
else:
	s = sum(a[0:k])
	t = sum(a[0:k])
	i = 0
	while i < n - k:
		t = t - a[i] + a[k + i]
		s += t
		i += 1
	print(s / (n - k + 1))