
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;
  a.(2*tl) <- 0;

  let b = Array.map (( * ) 2) a in
  for i = 1 to 2*tl do
    b.(i) <- min b.(i) (b.(i-1) + 1);
  done;
  for i = 2*tl-1 downto 0 do
    b.(i) <- min b.(i) (b.(i+1) + 1);
  done;

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