
let () =
  Scanf.scanf "%d" @@ fun n ->
  let ts = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let tl = Array.fold_left (+) 0 ts in
  let vs = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in

  let a = Array.make (2*tl+1) 0 in
  Array.fold_left (fun (c,i) t ->
    a.(c) <- min a.(c) vs.(i);
    Array.fill a (c+1) (2*t) vs.(i);
    (c+2*t, i+1)
  ) (0, 0) ts |> ignore;

  let b = Array.init (2*tl+1) (fun i ->
    Array.fold_left
      (fun (v,j) e -> (min v (2*e + abs (i-j)), j+1))
      (min i (2*tl-i), 0) a
    |> fst)
  in

  Array.fold_left (+) 0 b
  |> float_of_int
  |> fun z -> Printf.printf "%.10f\n" (z /. 4.0)