open Batteries
open BatPervasives
open Printf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> BatString.split_on_char ' '
  |> List.map cnv

let (n, k) = scan "%d %d" BatTuple.Tuple2.make
let ps = scan_list float_of_string

let exp n = n *. (n +. 1.0) /. 2.0 /. n

let rec zip xs = function
  | [] -> []
  | y::ys ->
    match xs with
    | [] -> []
    | z::zs -> (z, y)::zip zs ys

let rec hold_max m p = function
  | [] -> m
  | (x, y)::sumss ->
    let n = p -. x +. y in
    hold_max (if m > n then m else n) n sumss

let () =
  let sums = List.map exp ps in
  let init = BatList.fsum @@ BatList.take k sums in
  hold_max init init (zip sums @@ BatList.drop k sums)
  |> printf "%f\n"
