program test04
 implicit none
 integer N, K
 integer,allocatable :: a(:)
 double precision :: sumki=0
 double precision :: sumsai=0
 integer i,j

 read *, N, K
 allocate(a(N))
 read *, a

 do i=1,N-2
 sumki=0
  do j=1,K
  sumki = sumki + saiki(a(i+j-1))
  end do
  if ( sumki > sumsai ) sumsai = sumki
 end do
 
 print *, sumsai

contains
function saiki(pn)
 double precision saiki
 integer pn

 saiki = 0.5*(1+pn)

 end function

endprogram test04
