NEED HELP CP in 7 days contest problem

n,k = map(int,input().split())
a = [int(input()) for i in range(n)]
l,r = 0,0
ans = Sum = 0
while(r<n):
Sum+=a[r]
while(lk):
Sum-=a[l]
l+=1
N = r-l+1
ans+=N
r+=1
tot = (n*(n+1))/2
print(round(ans/tot,8))

Problem: Contest Page | CodeChef
My solution: Solution: 42214251 | CodeChef

Why my solution is wrong?
Can anyone please help me?